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,sz,m,a[50001],b[50001];
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%d",&a[i]),b[i]=a[i];
sort(a,a+n);
sz=unique(a,a+n)-a;
scanf("%d",&m);
if(m<=n){
printf("%d",b[m-1]);
return 0;
}
//for(int i=0;i<sz;i++)printf("%d ",a[i]);
//puts("");
int l=lower_bound(a,a+sz,sz)-a;
if(l==sz){
printf("%d",m-n-1+sz);
return 0;
}
else{
if(m-n-1+sz>=a[l]){
printf("%d",a[l]);
return 0;
}
printf("%d",m-n-1+sz);
}
}
# | 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... |