-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNOFIX1.java
More file actions
31 lines (26 loc) · 768 Bytes
/
Copy pathNOFIX1.java
File metadata and controls
31 lines (26 loc) · 768 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
import java.util.ArrayList;
import java.util.Scanner;
public class NOFIX1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Test cases
int T = scanner.nextShort();
for (int i = 1; i <= T; i++) {
// Input
int N = scanner.nextInt();
ArrayList<Long> A = new ArrayList<>();
for (int j = 0; j < N; j++) {
A.add(j, scanner.nextLong());
}
// Logic
int count = 0;
for (int j = 0; j < N; j++) {
if (A.get(j) - count == (j + 1)) {
count++;
}
}
// Output
System.out.println(count);
}
}
}