CF Bear and Game

来源:互联网 发布:视频播放器 for mac 编辑:程序博客网 时间:2024/04/29 13:44

Bear and Game

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

BearLimak likes watching sports on TV. He is going to watch a game today. The gamelasts 90 minutes and there are no breaks.

Eachminute can be either interesting or boring. If 15 consecutiveminutes are boring then Limak immediately turns TV off.

Youknow that there will be n interestingminutes t1, t2, ..., tn.Your task is to calculate for how many minutes Limak will watch the game.

描述

Limak喜欢看电视上的体育节目。他今天去看一场比赛。游戏持续90分钟,没有休息。

 

每分钟可以有趣或无聊。如果连续15分钟是无聊的,然后Limak立即把电视关掉。

 

你知道会有n个有趣的时间点,时间点分别是t1,t2,…,tn你的任务是计算有多少分钟Limak将观看比赛。

 

输入

输入的第一行包含一个整数n(1≤n≤90)-有趣的分钟数。

 

第二行包含n个整数t1,t2,…tn(1≤t1< t2 <…tn≤90),增加的顺序。

 

输出

打印的数量分钟Limak将观看比赛。

Input

Thefirst line of the input contains one integer n (1 ≤ n ≤ 90) —the number of interesting minutes.

Thesecond line contains n integers t1, t2, ..., tn (1 ≤ t1 < t2 < ... tn ≤ 90),given in the increasing order.

Output

Printthe number of minutes Limak will watch the game.

Sample Input

Input

3
7 20 88

Output

35

Input

9
16 20 30 40 50 60 70 80 90

Output

15

Input

9
15 20 30 40 50 60 70 80 90

Output

 90

 

 

 

题意:统计看电视的最多时间,如果无聊的时间间隔>15就不看电视,敲代码去。

 

代码如下:




 

/*=============================AC情况===============================*//*题目网址:   *//*时间: *//*心得: 看得懂英语,知道题目的题意很重要 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define G 100int main() {int n,t[G],ans;while(scanf("%d",&n)!=EOF) {for(int j=1; j<=n; j++)scanf("%d",&t[j]);ans=15;for (int j=1 ; j<=n; j++) {if (t[j] <= ans)ans = t[j] + 15;elsebreak;}if(ans>90)ans=90;printf("%d\n",ans);}return 0;}/*********************************测试数据***********************************************************************************************************/


 错误代码(没找到bug):

 

 

/*=============================AC情况===============================*//*题目网址:   *//*时间: *//*心得: 看得懂英语,知道题目的题意很重要 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define G 100int main() {int n,t[G],ans;while(scanf("%d",&n)!=EOF) {t[0]=0;//兴致勃勃的去看比赛 for(int j=1; j<n+1; j++)scanf("%d",&t[j]);/*if(t[1]>15) {printf("15\n");continue;}*/ans=0;for(int j=0; j<n; j++) {if(t[j+1]-t[j]<=15)//有趣的时间点持续更新中 ans=t[j+1];else {ans=ans+15;break;}}if(ans>90)ans=90;printf("%d\n",ans);}return 0;}/*********************************测试数据***********************************************************************************************************/

 

 

 



 
0 0
原创粉丝点击