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>
using namespace std;
int s[50001],b[50001];
int main (void)
{
int i,n,m,cnt=1,cnt2,mn=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&s[i]);
b[i]=s[i];
}
sort(b,b+n);
for(i=1;i<n;i++){
if(b[i-1]!=b[i])
cnt++;
}
scanf("%d",&m);
if(m<=n){
printf("%d\n",s[m-1]);
return 0;
}
cnt2=(m-n-1)+cnt;
for(i=0;i<n;i++){
if(cnt<=b[i] && b[i]<=cnt2){
if(mn==0)
mn=b[i];
else if(mn>b[i])
mn=b[i];
}
}
if(mn==0)
printf("%d\n",cnt2);
else
printf("%d\n",mn);
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... |