#include <stdio.h>
int N, M, inp[50005], chk[3000010], cnt, max;
int main()
{
//freopen("input.txt", "r", stdin);
int i, j;
scanf("%d", &N);
for(i = 1; i <= N; i ++)
{
scanf("%d", &inp[i]);
if(inp[i] > max) max = inp[i];
if(!chk[inp[i] + 1000000]) cnt ++, chk[inp[i] + 1000000] = 1;
}
scanf("%d", &M);
if(M <= N)
{
printf("%d\n", inp[M]);
return 0;
}
for(i = N+1; i <= M; i ++)
{
if(chk[cnt + 1000000])
{
printf("%d\n", cnt);
return 0;
}
if(cnt > max)
{
printf("%d\n", cnt + M - i);
return 0;
}
chk[cnt++ + 1000000] = 1;
}
printf("%d\n", --cnt);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
12996 KB |
Output is correct |
2 |
Correct |
0 ms |
12996 KB |
Output is correct |
3 |
Correct |
0 ms |
12996 KB |
Output is correct |
4 |
Correct |
0 ms |
12996 KB |
Output is correct |
5 |
Correct |
0 ms |
12996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
12996 KB |
Output is correct |
2 |
Correct |
0 ms |
12996 KB |
Output is correct |
3 |
Correct |
0 ms |
12996 KB |
Output is correct |
4 |
Correct |
0 ms |
12996 KB |
Output is correct |
5 |
Correct |
0 ms |
12996 KB |
Output is correct |
6 |
Correct |
0 ms |
12996 KB |
Output is correct |
7 |
Correct |
0 ms |
12996 KB |
Output is correct |
8 |
Correct |
0 ms |
12996 KB |
Output is correct |
9 |
Correct |
0 ms |
12996 KB |
Output is correct |
10 |
Correct |
0 ms |
12996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
12996 KB |
Output is correct |
2 |
Correct |
0 ms |
12996 KB |
Output is correct |
3 |
Correct |
0 ms |
12996 KB |
Output is correct |
4 |
Correct |
7 ms |
12996 KB |
Output is correct |
5 |
Correct |
7 ms |
12996 KB |
Output is correct |
6 |
Correct |
5 ms |
12996 KB |
Output is correct |
7 |
Correct |
0 ms |
12996 KB |
Output is correct |
8 |
Correct |
6 ms |
12996 KB |
Output is correct |
9 |
Correct |
0 ms |
12996 KB |
Output is correct |
10 |
Correct |
0 ms |
12996 KB |
Output is correct |
11 |
Correct |
0 ms |
12996 KB |
Output is correct |
12 |
Correct |
9 ms |
12996 KB |
Output is correct |
13 |
Correct |
0 ms |
12996 KB |
Output is correct |
14 |
Correct |
0 ms |
12996 KB |
Output is correct |
15 |
Correct |
0 ms |
12996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
12996 KB |
Output is correct |
2 |
Correct |
6 ms |
12996 KB |
Output is correct |
3 |
Correct |
7 ms |
12996 KB |
Output is correct |
4 |
Correct |
10 ms |
12996 KB |
Output is correct |
5 |
Correct |
2 ms |
12996 KB |
Output is correct |
6 |
Correct |
10 ms |
12996 KB |
Output is correct |
7 |
Correct |
5 ms |
12996 KB |
Output is correct |
8 |
Correct |
8 ms |
12996 KB |
Output is correct |
9 |
Correct |
8 ms |
12996 KB |
Output is correct |
10 |
Correct |
0 ms |
12996 KB |
Output is correct |
11 |
Correct |
7 ms |
12996 KB |
Output is correct |
12 |
Correct |
0 ms |
12996 KB |
Output is correct |
13 |
Correct |
0 ms |
12996 KB |
Output is correct |
14 |
Correct |
4 ms |
12996 KB |
Output is correct |
15 |
Correct |
8 ms |
12996 KB |
Output is correct |