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>
#define N 1000000
int chk[2*N+5],n,m,max,cnt,b[50005];
FILE *in,*out;
int main(){
int i,x;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&x);
if(chk[x+N]==1) continue;
chk[x+N]=1;
cnt++;
b[i]=x;
max=max>x?max:x;
}
scanf("%d",&m);
for(i=1;i<=n;i++){
if(i==m){
printf("%d\n",b[i]);
return 0;
}
}
if(cnt>max){
printf("%d\n",cnt+m-n-1);
return 0;
}
while(1){
if(chk[N+cnt]==1 || i==m){
printf("%d\n",cnt);
return 0;
}
chk[N+cnt]=1;
cnt++;
i++;
}
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... |