滴答滴啊--题目链接
Working time is the period of time that a person spends at paid labor.
You are given the working record of an employee containing the starting and ending time of work in n days. Your task is to determine if that employee worked sufficiently during these n days. An employee is considered to be worked sufficiently if the total number of working hours during the n days is at least m hours.
Input
The first line contains an integer T (1 ≤ T ≤ 300), in which T is the number of test cases.
The first line of each test case contains two integers n and m (1 ≤ n ≤ 100) (0 ≤ m ≤ 2400), in which n is the number of working days, and m is the minimum number of required working hours during these ndays.
Then n lines follow, each line contains two strings s and e, in which s is the starting time of work, and e is the ending time of work. Both times are given in the format hh:mm, where hh represents the hours and mm represents the minutes. It is guaranteed that the ending time is not less than the starting time, and both times will be in one day. Times are given in 24-hour time notation.
The sum of n overall test cases does not exceed 2 × 104.
Output
For each test case, print "YES" if the employee is considered to be worked sufficiently. Otherwise, print "NO".
Example
Input
3
2 15
08:00 16:00
07:55 16:12
2 20
08:00 18:30
07:30 17:00
3 35
10:00 16:00
08:05 16:37
11:07 15:30
Output
YES
YES
NO
Note
In the 24-hour time notation, the day begins at midnight, 00:00, and the last minute of the day begins at 23:59.
In this problem, the ending minute is not counted. For example, consider a person who started working at 00:00 and fished at 00:10, then the total number of working minutes is 10.
#include
#include
#include
#include
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k;
scanf("%d%d",&n,&k);
int x1,x2,y1,y2;
int ans=k*60;
int l,r;
int sum=0;
for(int i=1; i<=n; i++)
{
scanf("%d:%d %d:%d",&x1,&x2,&y1,&y2);
l=x1*60+x2;
r=y1*60+y2;
sum+=r-l;
}
if(sum>=ans)printf("YES\n");
else printf("NO\n");
}
return 0;
}