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 n,a[100005];
int main(){
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
}
int m;
scanf("%d",&m);
if(m <= n){
printf("%d",a[m-1]);
return 0;
}
m -= n;
sort(a,a+n);
a[n] = 2e9;
n++;
n = (int)(unique(a,a+n) - a);
int k = (int)(lower_bound(a,a+n,n-1) - a);
m--;
n--;
int dist = min(m,a[k] - n);
printf("%d",n + dist);
}
# | 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... |