Description
Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.
Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off.
You know that there will be n interesting minutes t1, t2, …, tn. Your task is to calculate for how many minutes Limak will watch the game.
【题目分析】
只要读懂题意,没有人做不出来的题目。纯模拟的题目好啊,妙啊!
【代码】
#include <cstdio>
#include <iostream>
#include <string>
int n,a[1001];
int min(int a,int b){return a<b?a:b;}
int main()
{
int n,x,last=0,ans=15;
scanf("%d",&n);
for (int i=1;i<=n;++i){
scanf("%d",&x);
if (last+15>=x) ans=x+15;
else break;
last=x;
}
printf("%d\n",min(ans,90));
return 0;
}
BearLimak喜欢观看电视上的体育赛事。如果连续15分钟的比赛无聊,他会立即关闭电视。已知比赛中有n个有趣的时刻发生在第t1, t2, ..., tn分钟。任务是计算BearLimak会观看比赛多少分钟。

183

被折叠的 条评论
为什么被折叠?



