#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
int a,b,i,s,p,x[55555],c[2000002],M=1000000;
main()
{
scanf("%d",&a);
for(i=1;i<=a;i++)
{
scanf("%d",&x[i]);
c[M+x[i]]++;
if(c[M+x[i]]==1)s++;
}
scanf("%d",&b);
if(b<=a)
{
printf("%d",x[b]);
return 0;
}
else
{
for(i=a+1;i<=b&&i<=M;i++)
{
if(c[s+M]==0)
{
c[s+M]=1;
s++;
}
else
{
p=1;
s++;
break;
}
}
if(b<=M)printf("%d",s-1);
else
{
if(p==1)printf("%d",s-1);
else
{
printf("%d",b-M+s-1);
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9112 KB |
Output is correct |
2 |
Correct |
0 ms |
9112 KB |
Output is correct |
3 |
Correct |
0 ms |
9112 KB |
Output is correct |
4 |
Correct |
0 ms |
9112 KB |
Output is correct |
5 |
Correct |
0 ms |
9112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9112 KB |
Output is correct |
2 |
Correct |
0 ms |
9112 KB |
Output is correct |
3 |
Correct |
0 ms |
9112 KB |
Output is correct |
4 |
Correct |
0 ms |
9112 KB |
Output is correct |
5 |
Correct |
0 ms |
9112 KB |
Output is correct |
6 |
Correct |
0 ms |
9112 KB |
Output is correct |
7 |
Correct |
0 ms |
9112 KB |
Output is correct |
8 |
Correct |
0 ms |
9112 KB |
Output is correct |
9 |
Correct |
0 ms |
9112 KB |
Output is correct |
10 |
Correct |
0 ms |
9112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9112 KB |
Output is correct |
2 |
Correct |
5 ms |
9112 KB |
Output is correct |
3 |
Correct |
3 ms |
9112 KB |
Output is correct |
4 |
Correct |
6 ms |
9112 KB |
Output is correct |
5 |
Correct |
14 ms |
9112 KB |
Output is correct |
6 |
Correct |
7 ms |
9112 KB |
Output is correct |
7 |
Correct |
2 ms |
9112 KB |
Output is correct |
8 |
Correct |
6 ms |
9112 KB |
Output is correct |
9 |
Correct |
1 ms |
9112 KB |
Output is correct |
10 |
Correct |
0 ms |
9112 KB |
Output is correct |
11 |
Correct |
2 ms |
9112 KB |
Output is correct |
12 |
Correct |
3 ms |
9112 KB |
Output is correct |
13 |
Correct |
0 ms |
9112 KB |
Output is correct |
14 |
Correct |
1 ms |
9112 KB |
Output is correct |
15 |
Correct |
4 ms |
9112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9112 KB |
Output is correct |
2 |
Correct |
0 ms |
9112 KB |
Output is correct |
3 |
Correct |
10 ms |
9112 KB |
Output is correct |
4 |
Correct |
0 ms |
9112 KB |
Output is correct |
5 |
Correct |
6 ms |
9112 KB |
Output is correct |
6 |
Correct |
0 ms |
9112 KB |
Output is correct |
7 |
Correct |
0 ms |
9112 KB |
Output is correct |
8 |
Correct |
0 ms |
9112 KB |
Output is correct |
9 |
Correct |
4 ms |
9112 KB |
Output is correct |
10 |
Correct |
9 ms |
9112 KB |
Output is correct |
11 |
Correct |
0 ms |
9112 KB |
Output is correct |
12 |
Correct |
13 ms |
9112 KB |
Output is correct |
13 |
Correct |
0 ms |
9112 KB |
Output is correct |
14 |
Correct |
15 ms |
9112 KB |
Output is correct |
15 |
Correct |
0 ms |
9112 KB |
Output is correct |