-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathALGOPRO7-src.cpp
41 lines (37 loc) · 970 Bytes
/
ALGOPRO7-src.cpp
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
import java.lang.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author thaic_000
*/
public class Main {
static int n, k;
static int MAX = 100006;
static int a[] = new int [MAX];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
k = sc.nextInt();
for (int i = 0; i < n; i++) a[i] = sc.nextInt();
Arrays.sort(a, 0, n);
int res = 0;
int p;
for (int i = 1; i <= n; i++){
if (a[i] != a[i - 1]){
p = i;
if (p >= k){
res = a[i];
break;
}
}
}
System.out.println(res);
}
}