intquick_select(int *nums, int l, int r, int k){ if (l >= r) { return nums[l]; }
int i = l - 1, j = r + 1; int x = nums[(l + r) / 2]; while (i < j) { do i++; while(nums[i] < x); do j--; while(nums[j] > x); if (i < j) swap(nums[i], nums[j]); } if (j - l + 1 >= k) returnquick_select(nums, l, j, k); elsereturnquick_select(nums, j + 1, r, k - (j - l + 1)); }
intmain(){ int N, k; cin >> N >> k; int nums[N]; for (int i = 0; i < N; i++) { cin >> nums[i]; }