-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2872.java
More file actions
55 lines (47 loc) · 1.28 KB
/
2872.java
File metadata and controls
55 lines (47 loc) · 1.28 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package algo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String args[]) throws IOException {
new Task().run();
}
static class Task {
private int N;
private int[] arr;
private StringTokenizer st = null;
private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
private StringTokenizer getStringTokenizer() throws IOException {
return new StringTokenizer(br.readLine(), " ");
}
private void input() throws IOException {
st = getStringTokenizer();
N = Integer.parseInt(st.nextToken());
arr = new int[N+1];
for(int i=1; i<=N; i++) {
st = getStringTokenizer();
arr[i] = Integer.parseInt(st.nextToken());
}
}
private void solution() throws IOException {
int here = N;
for(int i=N; i>=1; i--) {
if(here == arr[i]) here--;
}
bw.write(String.valueOf(here));
}
public void run() throws IOException {
input();
solution();
close();
}
private void close() throws IOException {
bw.close();
br.close();
}
}
}