#include <bits/stdc++.h>
using namespace std;
int N,M,u;
int S[50005];
int main(){
cin.sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>N;
for(int i=0;i<N;i++) cin>>S[i];
cin>>M;
if(M<=N) return !printf("%d\n",S[M-1]);
sort(S,S+N);
u=unique(S,S+N)-S;
if(u>S[u-1]) return !printf("%d\n",u+M-N-1);
if(u==*lower_bound(S,S+u,u)) return !printf("%d\n",u);
return !printf("%d\n",min(u+M-N-1,*lower_bound(S,S+u,u)));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2376 KB |
Output is correct |
2 |
Correct |
0 ms |
2376 KB |
Output is correct |
3 |
Correct |
0 ms |
2376 KB |
Output is correct |
4 |
Correct |
0 ms |
2376 KB |
Output is correct |
5 |
Correct |
0 ms |
2376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2376 KB |
Output is correct |
2 |
Correct |
0 ms |
2376 KB |
Output is correct |
3 |
Correct |
0 ms |
2376 KB |
Output is correct |
4 |
Correct |
0 ms |
2376 KB |
Output is correct |
5 |
Correct |
0 ms |
2376 KB |
Output is correct |
6 |
Correct |
0 ms |
2376 KB |
Output is correct |
7 |
Correct |
0 ms |
2376 KB |
Output is correct |
8 |
Correct |
0 ms |
2376 KB |
Output is correct |
9 |
Correct |
0 ms |
2376 KB |
Output is correct |
10 |
Correct |
0 ms |
2376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2376 KB |
Output is correct |
2 |
Correct |
9 ms |
2376 KB |
Output is correct |
3 |
Correct |
3 ms |
2376 KB |
Output is correct |
4 |
Correct |
3 ms |
2376 KB |
Output is correct |
5 |
Correct |
0 ms |
2376 KB |
Output is correct |
6 |
Correct |
3 ms |
2376 KB |
Output is correct |
7 |
Correct |
3 ms |
2376 KB |
Output is correct |
8 |
Correct |
0 ms |
2376 KB |
Output is correct |
9 |
Correct |
9 ms |
2376 KB |
Output is correct |
10 |
Correct |
9 ms |
2376 KB |
Output is correct |
11 |
Correct |
0 ms |
2376 KB |
Output is correct |
12 |
Correct |
6 ms |
2376 KB |
Output is correct |
13 |
Correct |
3 ms |
2376 KB |
Output is correct |
14 |
Correct |
6 ms |
2376 KB |
Output is correct |
15 |
Correct |
0 ms |
2376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2376 KB |
Output is correct |
2 |
Correct |
13 ms |
2376 KB |
Output is correct |
3 |
Correct |
0 ms |
2376 KB |
Output is correct |
4 |
Correct |
6 ms |
2376 KB |
Output is correct |
5 |
Correct |
6 ms |
2376 KB |
Output is correct |
6 |
Correct |
6 ms |
2376 KB |
Output is correct |
7 |
Correct |
0 ms |
2376 KB |
Output is correct |
8 |
Correct |
3 ms |
2376 KB |
Output is correct |
9 |
Correct |
0 ms |
2376 KB |
Output is correct |
10 |
Correct |
6 ms |
2376 KB |
Output is correct |
11 |
Correct |
6 ms |
2376 KB |
Output is correct |
12 |
Correct |
3 ms |
2376 KB |
Output is correct |
13 |
Correct |
6 ms |
2376 KB |
Output is correct |
14 |
Correct |
13 ms |
2376 KB |
Output is correct |
15 |
Correct |
6 ms |
2376 KB |
Output is correct |