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, M, d=1;
int S[50050];
int main()
{
int i;
scanf("%d",&N);
for(i=1;i<=N;++i) scanf("%d",S+i);
scanf("%d",&M);
if(M<=N){
printf("%d",S[M]);
return 0;
}
sort(S+1,S+N+1);
for(i=1;i<N;++i) if(S[i]!=S[i+1]) ++d;
for(i=1;i<=N;++i) if(d<=S[i]) break;
S[N+1]=0x7FFFFFFF;
printf("%d",min(S[i],d+M-N-1));
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... |