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 n,m;
int a[110000],cnt=0,Mnt;
int check[2000100];
int main()
{
scanf("%d",&n);
int i,f=0;
for(i = 1 ; i <= n ; i++){
scanf("%d",&a[i]);
if(check[a[i]+1000000]==0)cnt++;
check[a[i]+1000000]=1;
}
scanf("%d",&m);
if(m <= n){
printf("%d",a[m]);
}
else
{
Mnt=m-n+cnt-1;
sort(a+1,a+n+1);
for(i = 1 ; i <= n ; i++){
if(a[i]<cnt)continue;
if(a[i]>=Mnt)break;
f=1;
printf("%d",a[i]);
break;
}
if(f==0)printf("%d",Mnt);
}
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... |