CF Bear and Game

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 100

int 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;
			else
				break;
		}
		if(ans>90)
			ans=90;
		printf("%d\n",ans);
	}
	return 0;
}

/*********************************测试数据*********************************


**************************************************************************/


 错误代码(没找到bug):

 

 

/*=============================AC情况===============================*/
/*题目网址:   */
/*时间: */
/*心得: 看得懂英语,知道题目的题意很重要 */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define G 100

int 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;
}

/*********************************测试数据*********************************


**************************************************************************/

 

 

 



 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值