【Codeforces】967A Mind the Gap【暴力】

##【Codeforces】967A Mind the Gap
【题目大意】

给你一个由h(小时)和m(分钟)组成的飞机起飞的序列,让你找一个时间,使这个时间距相邻两架飞机起飞的时间至少S+1,找出最早的。

【题解】

这题很水,就枚举一个位置然后插入就可以了,注意开头和结尾就OK了。

【代码如下】

#include<cstdio>
using namespace std;
int n,S;
int main(){
//	freopen("A.in","r",stdin);
//	freopen("A.out","w",stdout);
	scanf("%d%d",&n,&S);
	int lsth=0,lstt=-S-1,lst=-S-1;//开头
	int nowh=0,nowt=0,now=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&nowh,&nowt);
		now=nowh*60+nowt;
		if(now-lst>=2*S+2){
			nowh=lsth+(lstt+S+1)/60;
			nowt=(lstt+S+1)%60;
			printf("%d %d\n",nowh,nowt);
			return 0;
		}
		lst=now;lsth=nowh;lstt=nowt;
	}
	nowh=lsth+(lstt+S+1)/60;//结尾
	nowt=(lstt+S+1)%60;
	printf("%d %d\n",nowh,nowt);
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值