我这个蒟蒻又来做CF了
我做的是
“Everyone Loves to Sleep”
“每个人都喜欢睡觉”
Vlad, like everyone else, loves to sleep very much.
Every day Vlad has to do n things, each at a certain time. For each of these things, he has an alarm
clock set, the i -th of them is triggered on ℎ hi hours mi minutes every day (hi<24,0≤mi<60 ).
Vlad uses the 2424 -hour time format, so after ℎ=12,m=59;h=12,m=59 comes ℎ=13,m=0h=13,m=0 and after ℎ=23,m=59;h=23,m=59 comes ℎ=0,m=0.
This time Vlad went to bed at H hours M minutes ( 0≤H<24,0≤M<60 ) and asks you to answer: how much he will be able to sleep until the next alarm clock.
If any alarm clock rings at the time when he went to bed, then he will sleep for a period of time of length 0.
Vlad和其他人一样,非常喜欢睡觉。
Vlad每天都要做 n 件事,每件事在特定时间。对于这些事情中的每一件,他都定了一个闹钟,其中第 i 个在 hi 时 mi 分被触发(0≤ℎ<24,0≤m<60)。
Vlad使用24小时时间格式,所以12:59之后是13:00,23:59后是00:00。
Vlad在H时M分睡觉(0≤n<24,0≤m<60)。
他要你回答:在下一个闹钟响之前,他能睡多久。
如果在他上床睡觉的时候有任何闹钟响起,那么他将睡0小时0分钟。
输入样例:
3
1 6 13
8 0
3 6 0
12 30
14 45
6 0
2 23 35
20 15
10 30
输出样例:
1 47
0 0
10 55
代码:
#include<bits/stdc++.h>
using namespace std;
int t,n,h,m,h1,m1,anst;
int main(){
cin >> t;
while(t--){ // 非0的都是true
cin >> n >> h >> m;// 闹钟,小时,分钟
int t1,t2,anst=0,minn=1e9,f=0;
t1 = h*60+m;//现在睡的时间
for(int i=1;i<=n;i++){
cin >> h1 >> m1;
t2 = h1*60 + m1;
if(t1<t2) //当天醒了
anst = t2 - t1;
else if(t1>t2){//隔天醒
anst = 24*60-t1+t2;
}else f = 1;
minn = min(minn,anst);
}
if(f) cout << "0 0\n";//\n换行
else cout << minn/60 << " " << minn%60 << endl;
}
return 0;//完结撒花
}
标签:Vlad,13,Everyone,59,23,CF,12,Loves,time
From: https://blog.csdn.net/2401_85107998/article/details/139182548