voidswap(int& x, int& y){ if (x == y) return; x ^= y; y ^= x; x ^= y; }
intpartition(int nums[], int left, int right){ int i = left, j = right - 1; swap(nums[left], nums[(left + right) >> 1]); int pivot = nums[left]; while (i < j) { while (i < j && pivot < nums[j]) j--; if (i < j) nums[i++] = nums[j]; while (i < j && nums[i] < pivot) i++; if (i < j) nums[j--] = nums[i]; } nums[i] = pivot; return i; }
intk_select(int nums[], int left, int right, int k){ while (left < right) { int pos = partition(nums, left, right); if (k < pos) { right = pos; } elseif (k > pos) { left = pos; } elsereturn nums[pos]; } return nums[left]; }
intmain(){ int n, k; scanf("%d %d", &n, &k); int nums[n]; N = n; for (int i = 0; i < n; i++) scanf("%d ", &nums[i]); int k_th = k_select(nums, 0, n, k - 1); printf("%d", k_th); }