-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBearAndGame.java
More file actions
31 lines (28 loc) · 838 Bytes
/
BearAndGame.java
File metadata and controls
31 lines (28 loc) · 838 Bytes
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
27
28
29
30
31
/* https://codeforces.com/contest/673/problem/A
tag: #implementation
get the last minute that Bear Limark can watch,
and compare with the next interesting minute.
*/
import java.util.Scanner;
public class BearAndGame {
static int watchingTvMininues() {
Scanner obj = new Scanner(System.in);
int number = obj.nextInt();
int lastMinuteCanWatchTv = 15;
for (int i = 0; i < number; i++) {
int nextInterestingMinute = obj.nextInt();
if (nextInterestingMinute > lastMinuteCanWatchTv) {
break;
}
lastMinuteCanWatchTv = nextInterestingMinute + 15;
}
// the game lasts 90 minutes
if (lastMinuteCanWatchTv > 90) {
return 90;
}
return lastMinuteCanWatchTv;
}
public static void main(String argrs[]) {
System.out.println(watchingTvMininues());
}
}