-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhighcard.java
46 lines (32 loc) · 1.02 KB
/
highcard.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
41
42
43
44
45
46
import java.io.*;
import java.util.*;
public class highcard {
public static void main(String[] args) throws IOException {
// write your code here
BufferedReader f = new BufferedReader(new FileReader("highcard.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("highcard.out")));
int n = Integer.parseInt(f.readLine());
ArrayList<Integer> bess = new ArrayList<Integer>();
ArrayList<Integer> other = new ArrayList<Integer>();
boolean[] k = new boolean[2*n];
for(int i = 0; i<n;i++){
k[Integer.parseInt(f.readLine())-1] = true;
}
for(int i = 0; i<2*n;i++){
if(k[i]){
other.add(i);
}
else {
bess.add(i);
}
}
int count = 0;
for(int i = 0; i<bess.size();i++){
if(bess.get(i)>other.get(count)){
count++;
}
}
out.println(count);
out.close();
}
}