-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP11004.java
More file actions
31 lines (27 loc) · 711 Bytes
/
P11004.java
File metadata and controls
31 lines (27 loc) · 711 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
package BOJ;
import java.io.*;
public class P11004 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int k = Integer.parseInt(input[1]);
int[] a = new int[5000001];
input = br.readLine().split(" ");
for(int i=0;i<n;i++){
int value = Integer.parseInt(input[i]);
a[value]++;
}
int index = 0;
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
for(int i=1;i<a.length;i++){
if(a[i]==0) continue;
index++;
if(index==k){
bw.write((int)i);
bw.flush();
return;
}
}
}
}