zoukankan      html  css  js  c++  java
  • codeforces 673A A. Bear and Game(水题)

    题目链接:

    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.

    题意

    给这么多时间点,这些时间点是interesting的点,如果连续15分钟不出现interesting的点的话,就要换了;问最长能看多上时间;

    思路

    那就看相邻的点的间隔是不是长于15了,还有就是这个节目一共长90分钟;

    AC代码

    #include <bits/stdc++.h>
    using namespace std;
    #define Riep(n) for(int i=1;i<=n;i++)
    #define Riop(n) for(int i=0;i<n;i++)
    #define Rjep(n) for(int j=1;j<=n;j++)
    #define Rjop(n) for(int j=0;j<n;j++)
    #define mst(ss,b) memset(ss,b,sizeof(ss));
    typedef long long LL;
    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const int inf=0x3f3f3f3f;
    const int N=1e5+5;
    int n,a[200];
    int main()
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        a[0]=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]-a[i-1]>15)
            {
                cout<<a[i-1]+15<<endl;
                return 0;
            }
        }
        cout<<min(90,a[n]+15)<<endl;
    
        return 0;
    }
  • 相关阅读:
    贝叶斯分类器介绍
    XGBOOST应用及调参示例
    GBDT和XGBOOST算法原理
    CART决策树和随机森林
    PCA与LDA介绍
    回归分析介绍
    KVM图形化管理虚拟机键盘无反应解决办法
    第一次安装CentOs7没有设置root密码,后续启动centos7无法登录------解决办法
    Centos7系统中nginx+tomcat 出现错误 502 Bad Gateway
    Centos7系统中安装Nginx服务
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5470073.html
Copyright © 2011-2022 走看看