CF Everyone Loves to Sleep 每个人都喜欢睡觉

我这个蒟蒻又来做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;//完结撒花
}

  • 28
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值