AcWing 3533. 查找第K小数
原题链接
简单
作者:
JustDoIt11
,
2023-10-01 08:45:30
,
所有人可见
,
阅读 85
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i ++ ) {
arr[i] = sc.nextInt();
}
int k = sc.nextInt();
Arrays.sort(arr);
int now = 0; int la = -1;
int i;
for (i = 0; i < n; i ++ ) {
if (arr[i] != la) {
la = arr[i];
now ++ ;
}
if (now == k) break;
}
System.out.println(arr[i]);
}
}