-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dvds.java
40 lines (29 loc) · 923 Bytes
/
Dvds.java
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
/*
Problem: https://open.kattis.com/problems/dvds
Author: Adrian Reithaug
Submitted: June 23rd, 2017
Time: 1.36s / 4.00s
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Dvds {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int numCases = Integer.parseInt(reader.readLine());
while (numCases-- > 0) {
reader.readLine();
String[] dvds = reader.readLine().split(" ");
int operations = 0;
int position = 1;
for (String dvd : dvds) {
if (position != Integer.parseInt(dvd)) {
operations++;
} else {
position++;
}
}
System.out.println(operations);
}
}
}