Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A. Bear and Game 水题
A. Bear and Game
题目连接:
http://www.codeforces.com/contest/673/problem/A
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
3
7 20 88
Sample Output
35
题意
有一个90分钟的球赛,有n个分钟是有趣的,如果连着15分钟都是无趣的话,这个人就会离开
问你这个人看了多久的电视
题解:
数据范围才90,我还能说什么呢?
直接暴力吧
代码
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int v[100];
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x;scanf("%d",&x);
v[x]=1;
}
int now=0,sum=0;
for(int i=1;i<=90;i++)
{
sum++;
if(v[i])now=0;
else now++;
if(now==15)
{
break;
}
}
printf("%d\n",sum);
}