-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBJAlgo_1668.java
More file actions
35 lines (30 loc) · 995 Bytes
/
Copy pathBJAlgo_1668.java
File metadata and controls
35 lines (30 loc) · 995 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
32
33
34
35
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class BJAlgo_1668 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] trophies = new int[n];
for (int i = 0; i < trophies.length; i++) {
trophies[i] = Integer.parseInt(br.readLine());
}
int leftMax = 0;
int left = 0;
for (int i = 0; i < trophies.length; i++) {
if (leftMax < trophies[i]) {
left += 1;
leftMax = trophies[i];
}
}
int rightMax = 0;
int right = 0;
for (int i = trophies.length - 1; i >= 0; i--) {
if (rightMax < trophies[i]) {
right += 1;
rightMax = trophies[i];
}
}
System.out.println(left);
System.out.println(right);
}
}