#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);
b[i]=x;
if(chk[x+N]==1) continue;
chk[x+N]=1;
cnt++;
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 |
1 |
Correct |
0 ms |
9092 KB |
Output is correct |
2 |
Correct |
0 ms |
9092 KB |
Output is correct |
3 |
Correct |
0 ms |
9092 KB |
Output is correct |
4 |
Correct |
0 ms |
9092 KB |
Output is correct |
5 |
Correct |
0 ms |
9092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9092 KB |
Output is correct |
2 |
Correct |
0 ms |
9092 KB |
Output is correct |
3 |
Correct |
0 ms |
9092 KB |
Output is correct |
4 |
Correct |
0 ms |
9092 KB |
Output is correct |
5 |
Correct |
0 ms |
9092 KB |
Output is correct |
6 |
Correct |
0 ms |
9092 KB |
Output is correct |
7 |
Correct |
1 ms |
9092 KB |
Output is correct |
8 |
Correct |
0 ms |
9092 KB |
Output is correct |
9 |
Correct |
0 ms |
9092 KB |
Output is correct |
10 |
Correct |
0 ms |
9092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
9092 KB |
Output is correct |
2 |
Correct |
0 ms |
9092 KB |
Output is correct |
3 |
Correct |
12 ms |
9092 KB |
Output is correct |
4 |
Correct |
7 ms |
9092 KB |
Output is correct |
5 |
Correct |
0 ms |
9092 KB |
Output is correct |
6 |
Correct |
5 ms |
9092 KB |
Output is correct |
7 |
Correct |
0 ms |
9092 KB |
Output is correct |
8 |
Correct |
12 ms |
9092 KB |
Output is correct |
9 |
Correct |
0 ms |
9092 KB |
Output is correct |
10 |
Correct |
0 ms |
9092 KB |
Output is correct |
11 |
Correct |
0 ms |
9092 KB |
Output is correct |
12 |
Correct |
9 ms |
9092 KB |
Output is correct |
13 |
Correct |
0 ms |
9092 KB |
Output is correct |
14 |
Correct |
8 ms |
9092 KB |
Output is correct |
15 |
Correct |
0 ms |
9092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9092 KB |
Output is correct |
2 |
Correct |
2 ms |
9092 KB |
Output is correct |
3 |
Correct |
10 ms |
9092 KB |
Output is correct |
4 |
Correct |
0 ms |
9092 KB |
Output is correct |
5 |
Correct |
0 ms |
9092 KB |
Output is correct |
6 |
Correct |
0 ms |
9092 KB |
Output is correct |
7 |
Correct |
7 ms |
9092 KB |
Output is correct |
8 |
Correct |
3 ms |
9092 KB |
Output is correct |
9 |
Correct |
9 ms |
9092 KB |
Output is correct |
10 |
Correct |
9 ms |
9092 KB |
Output is correct |
11 |
Correct |
13 ms |
9092 KB |
Output is correct |
12 |
Correct |
0 ms |
9092 KB |
Output is correct |
13 |
Correct |
0 ms |
9092 KB |
Output is correct |
14 |
Correct |
6 ms |
9092 KB |
Output is correct |
15 |
Correct |
0 ms |
9092 KB |
Output is correct |