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 <stdio.h>
#include <algorithm>
#define INF 0x7fffffff
using namespace std;
int N, S[50001], M, K, Ans;
int main(void) {
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]);
else {
sort(S+1,S+N+1);
S[0]=-INF;
for(i=1 ; i<=N ; i++)
if(S[i]!=S[i-1]) K++;
Ans=K+M-N-1;
for(i=1 ; i<=N ; i++) if(K<=S[i] && S[i]<=K+M-N-1 && Ans>S[i]) Ans=S[i];
printf("%d",Ans);
}
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... |