#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[100005];
int main(){
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
}
int m;
scanf("%d",&m);
if(m <= n){
printf("%d",a[m-1]);
return 0;
}
m -= n;
sort(a,a+n);
a[n] = 2e9;
n++;
n = (int)(unique(a,a+n) - a);
int k = (int)(lower_bound(a,a+n,n-1) - a);
m--;
n--;
int dist = min(m,a[k] - n);
printf("%d",n + dist);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1472 KB |
Output is correct |
2 |
Correct |
0 ms |
1472 KB |
Output is correct |
3 |
Correct |
0 ms |
1472 KB |
Output is correct |
4 |
Correct |
0 ms |
1472 KB |
Output is correct |
5 |
Correct |
0 ms |
1472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1472 KB |
Output is correct |
2 |
Correct |
0 ms |
1472 KB |
Output is correct |
3 |
Correct |
0 ms |
1472 KB |
Output is correct |
4 |
Correct |
0 ms |
1472 KB |
Output is correct |
5 |
Correct |
0 ms |
1472 KB |
Output is correct |
6 |
Correct |
0 ms |
1472 KB |
Output is correct |
7 |
Correct |
0 ms |
1472 KB |
Output is correct |
8 |
Correct |
0 ms |
1472 KB |
Output is correct |
9 |
Correct |
0 ms |
1472 KB |
Output is correct |
10 |
Correct |
0 ms |
1472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1472 KB |
Output is correct |
2 |
Correct |
13 ms |
1472 KB |
Output is correct |
3 |
Correct |
8 ms |
1472 KB |
Output is correct |
4 |
Correct |
10 ms |
1472 KB |
Output is correct |
5 |
Correct |
0 ms |
1472 KB |
Output is correct |
6 |
Correct |
0 ms |
1472 KB |
Output is correct |
7 |
Correct |
14 ms |
1472 KB |
Output is correct |
8 |
Correct |
0 ms |
1472 KB |
Output is correct |
9 |
Correct |
0 ms |
1472 KB |
Output is correct |
10 |
Correct |
0 ms |
1472 KB |
Output is correct |
11 |
Correct |
0 ms |
1472 KB |
Output is correct |
12 |
Correct |
5 ms |
1472 KB |
Output is correct |
13 |
Correct |
0 ms |
1472 KB |
Output is correct |
14 |
Correct |
8 ms |
1472 KB |
Output is correct |
15 |
Correct |
0 ms |
1472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1472 KB |
Output is correct |
2 |
Correct |
10 ms |
1472 KB |
Output is correct |
3 |
Correct |
0 ms |
1472 KB |
Output is correct |
4 |
Correct |
6 ms |
1472 KB |
Output is correct |
5 |
Correct |
0 ms |
1472 KB |
Output is correct |
6 |
Correct |
5 ms |
1472 KB |
Output is correct |
7 |
Correct |
14 ms |
1472 KB |
Output is correct |
8 |
Correct |
11 ms |
1472 KB |
Output is correct |
9 |
Correct |
15 ms |
1472 KB |
Output is correct |
10 |
Correct |
0 ms |
1472 KB |
Output is correct |
11 |
Correct |
0 ms |
1472 KB |
Output is correct |
12 |
Correct |
15 ms |
1472 KB |
Output is correct |
13 |
Correct |
0 ms |
1472 KB |
Output is correct |
14 |
Correct |
14 ms |
1472 KB |
Output is correct |
15 |
Correct |
0 ms |
1472 KB |
Output is correct |