CodeForces673ABear and Game

来源:互联网 发布:中国文化产业现状知乎 编辑:程序博客网 时间:2024/06/05 03:49

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.

Input

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

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

Output

Print the number of minutes Limak will watch the game.

Sample Input

Input
37 20 88
Output
35
Input
916 20 30 40 50 60 70 80 90
Output
15
Input
915 20 30 40 50 60 70 80 90
Output
90
代码:
#include<iostream>#include<algorithm>#include<string.h>#include<stdio.h>using namespace std;int main(){int n;while(scanf("%d",&n)!=EOF){int i,a[91];memset(a,0,sizeof(a));for(int i=1;i<=n;i++){scanf("%d",&a[i]);}for(i=1;i<=n;i++){if(i!=n){if(a[i]-a[i-1]>15){printf("%d\n",a[i-1]+15);break;}}else{if(a[i]-a[i-1]>15)printf("%d\n",a[i-1]+15);else{if(a[i]>=75)printf("90\n");elseprintf("%d\n",a[i]+15);}}}}return 0;}
题意:
一个人看一场90分钟球赛,球赛中会有精彩镜头。如果连续15分钟没有精彩镜头他就不看了。给你一场比赛的所有精彩镜头的时间,问你他能看多少分钟比赛。
思路:建立一个数组判断相邻之间是否超过15分钟就行。要注意特殊值,比如一直看到最后不小于75分钟时 ,那么他就一定会看完了90分钟。

0 0
原创粉丝点击