-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBj17608Stack.java
More file actions
29 lines (26 loc) · 814 Bytes
/
Copy pathBj17608Stack.java
File metadata and controls
29 lines (26 loc) · 814 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
package baekjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Stack;
public class Bj17608Stack {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Stack<Integer> stack = new Stack<>();
int n = Integer.parseInt(br.readLine());
for (int i = 0; i < n; i++) {
stack.push(Integer.parseInt(br.readLine()));
}
int temp = 0;
int count = 0;
for (int i = 0; i < n; i++) {
int first = stack.pop();
if (first > temp) {
temp = first;
count++;
}
}
System.out.println(count);
}
}