#include <cstdio>
#include <algorithm>
using namespace std;
int N, M, d=1;
int S[50050];
int main()
{
int i;
scanf("%d",&N);
for(i=1;i<=N;++i) scanf("%d",S+i);
scanf("%d",&M);
if(M<=N){
printf("%d",S[M]);
return 0;
}
sort(S+1,S+N+1);
for(i=1;i<N;++i) if(S[i]!=S[i+1]) ++d;
for(i=1;i<=N;++i) if(d<=S[i]) break;
S[N+1]=0x7FFFFFFF;
printf("%d",min(S[i],d+M-N-1));
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1280 KB |
Output is correct |
2 |
Correct |
0 ms |
1280 KB |
Output is correct |
3 |
Correct |
0 ms |
1280 KB |
Output is correct |
4 |
Correct |
0 ms |
1280 KB |
Output is correct |
5 |
Correct |
0 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1280 KB |
Output is correct |
2 |
Correct |
0 ms |
1280 KB |
Output is correct |
3 |
Correct |
0 ms |
1280 KB |
Output is correct |
4 |
Correct |
0 ms |
1280 KB |
Output is correct |
5 |
Correct |
0 ms |
1280 KB |
Output is correct |
6 |
Correct |
0 ms |
1280 KB |
Output is correct |
7 |
Correct |
0 ms |
1280 KB |
Output is correct |
8 |
Correct |
0 ms |
1280 KB |
Output is correct |
9 |
Correct |
0 ms |
1280 KB |
Output is correct |
10 |
Correct |
0 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1280 KB |
Output is correct |
2 |
Correct |
0 ms |
1280 KB |
Output is correct |
3 |
Correct |
5 ms |
1280 KB |
Output is correct |
4 |
Correct |
7 ms |
1280 KB |
Output is correct |
5 |
Correct |
7 ms |
1280 KB |
Output is correct |
6 |
Correct |
0 ms |
1280 KB |
Output is correct |
7 |
Correct |
0 ms |
1280 KB |
Output is correct |
8 |
Correct |
14 ms |
1280 KB |
Output is correct |
9 |
Correct |
0 ms |
1280 KB |
Output is correct |
10 |
Correct |
0 ms |
1280 KB |
Output is correct |
11 |
Correct |
10 ms |
1280 KB |
Output is correct |
12 |
Correct |
12 ms |
1280 KB |
Output is correct |
13 |
Correct |
1 ms |
1280 KB |
Output is correct |
14 |
Correct |
0 ms |
1280 KB |
Output is correct |
15 |
Correct |
3 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1280 KB |
Output is correct |
2 |
Correct |
10 ms |
1280 KB |
Output is correct |
3 |
Correct |
5 ms |
1280 KB |
Output is correct |
4 |
Correct |
0 ms |
1280 KB |
Output is correct |
5 |
Correct |
13 ms |
1280 KB |
Output is correct |
6 |
Correct |
0 ms |
1280 KB |
Output is correct |
7 |
Correct |
9 ms |
1280 KB |
Output is correct |
8 |
Correct |
14 ms |
1280 KB |
Output is correct |
9 |
Correct |
0 ms |
1280 KB |
Output is correct |
10 |
Correct |
2 ms |
1280 KB |
Output is correct |
11 |
Correct |
12 ms |
1280 KB |
Output is correct |
12 |
Correct |
7 ms |
1280 KB |
Output is correct |
13 |
Correct |
14 ms |
1280 KB |
Output is correct |
14 |
Correct |
10 ms |
1280 KB |
Output is correct |
15 |
Correct |
6 ms |
1280 KB |
Output is correct |