• 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 }
  • 相关阅读:
    sqlserver数据导入导出问题
    关于数据库冗余设计的思考
    cordova插件开发注意事项
    阿里云旺集成问题
    aspnet webapi 跨域请求 405错误
    跨域无法获取自定义header的问题
    angular input标签只能单向传递数据的问题
    android audio无法自动播放
    jquery mobile 问问多多
    mysql 表表连接的问题。
  • 原文地址:https://www.cnblogs.com/hsd-/p/5469647.html
Copyright © 2020-2023  润新知