【CodeForces】[673A]Bear and Game

Problem Description

Loading...

Problem Analysis

Since the problem states it lasts at most 90 minutes, we can simulate the process of watching TV with a loop and thereby count the maximum number of minutes that can be watched.

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#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\n",res);
	}
	return 0;
}

Problem address: 【CodeForces】[673A]Bear and Game

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...