Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) 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
題意
有一個(gè)90分鐘的球賽,有n個(gè)分鐘是有趣的,如果連著15分鐘都是無趣的話,這個(gè)人就會離開
問你這個(gè)人看了多久的電視
題解:
數(shù)據(jù)范圍才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); }總結(jié)
以上是生活随笔為你收集整理的Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A. Bear and Game 水题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 从零开始学_JavaScript_系列(
- 下一篇: 对象的继承关系在数据库中的实现方式和Po