-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBJAlgo_1847.java
More file actions
38 lines (32 loc) · 1.04 KB
/
Copy pathBJAlgo_1847.java
File metadata and controls
38 lines (32 loc) · 1.04 KB
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
36
37
38
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class BJAlgo_1847 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int count = Integer.parseInt(br.readLine());
List stack = new ArrayList();
List result = new ArrayList();
int top = 1;
for (int i = 0; i < count; i++) {
int num = Integer.parseInt(br.readLine());
while (top <= num) {
stack.add(top);
result.add("+");
top += 1;
}
if ((int) stack.get(stack.size() - 1) == num) {
stack.remove(stack.size() - 1);
result.add("-");
} else {
result.clear();
result.add("NO");
break;
}
}
for (int i = 0; i < result.size(); i++) {
System.out.println(result.get(i));
}
}
}