【CodeForces】[673A]Bear and Game

这里写图片描述

因为已经说最多持续90分钟
所以可以进行循环模拟看电视的过程
从而统计最多可看几分钟

#include<stdio.h>
#include<string.h>
int a[100];
int main() {
    int n;
    while(scanf("%d",&n)!=EOF) {
        memset(a,0,sizeof(a));
        for(int i=1; i<=n; i++) {
            int t;
            scanf("%d",&t);
            a[t]=1;
        }
        int res=0,t=0;
        for(int i=1; i<=90; i++) {
            res++;
            if(a[i])
                t=0;
            else
                t++;
            if(t>=15)
                break;
        }
        printf("%d
",res);
    }
    return 0;
}

题目地址:【CodeForces】[673A]Bear and Game

原文地址:https://www.cnblogs.com/BoilTask/p/12569554.html