This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[50000];
int main() {
int N, i, differ = 1, sup = 1000001, ord, tst;
scanf("%d", &N);
for (i=0; i<N; ++i) {
scanf("%d", arr+i);
}
scanf("%d", &ord);
if (ord <= N) {
printf("%d\n", arr[ord - 1]);
return 0;
}
stable_sort(arr, arr+N);
for (i=1; i<N; ++i) {
differ += (arr[i] != arr[i - 1]);
}
for (i=0; i<N; ++i) {
if (arr[i] >= differ) {
sup = arr[i];
break;
}
}
tst = ord - (N + 1) + differ;
if (i < N && tst >= sup) tst = sup;
printf("%d\n", tst);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |