zoukankan      html  css  js  c++  java
  • Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A

    A. Bear and Game
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Examples
    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
    Note

    In the first sample, minutes 21, 22, ..., 35 are all boring and thus Limak will turn TV off immediately after the 35-th minute. So, he would watch the game for 35 minutes.

    In the second sample, the first 15 minutes are boring.

    In the third sample, there are no consecutive 15 boring minutes. So, Limak will watch the whole game.

    题意:n个有趣时间点 当持续15分钟没有遇到有趣时间点 则截至  输出持续的总时间

    题解:记录有趣时间点  for循环寻找 截至点并且输出   未找到则输出90

     1 #include<bits/stdc++.h>
     2 #include<iostream>
     3 #include<cstring>
     4 #include<cstdio>
     5 #include<queue>
     6 #include<stack>
     7 #include<map>
     8 #define ll __int64
     9 #define pi acos(-1.0)
    10 using namespace std;
    11 int n;
    12 map<int,int> mp;
    13 int exm;
    14 int ans;
    15 int main()
    16 {
    17     int n;
    18     scanf("%d",&n);
    19     mp.clear();
    20     for(int i=1;i<=n;i++)
    21     {
    22         scanf("%d",&exm);
    23         mp[exm]=1;
    24     }
    25     int gg=0;
    26     ans=0;
    27     for(int i=1;i<=90;i++)
    28     {
    29         if(mp[i])
    30         gg=i;
    31         if(i-gg>14)
    32         {
    33             ans=i;
    34             break;
    35         }
    36     }
    37     if(ans==0)
    38     cout<<"90"<<endl;
    39     else
    40     cout<<ans<<endl;
    41     return 0;
    42 }
  • 相关阅读:
    LeetCode449. 序列化和反序列化二叉搜索树
    LeetCode448. 找到所有数组中消失的数字
    一行代码如何隐藏 Linux 进程?
    C语言这么厉害,它自身又是用什么语言写的?
    了解C语言,是否代表了解C ++的一半?
    C语言小白那些不知道的事儿
    6 条 Git 实用技巧
    干货来袭,收藏方便找到该网站
    零基础小白如何入门Shell,快来看看(收藏)这篇大总结!!
    Java用于嵌入式系统的优点和局限
  • 原文地址:https://www.cnblogs.com/hsd-/p/5469647.html
Copyright © 2011-2022 走看看