#include<stdio.h>
#include<algorithm>
#define N 50001
int n,m,a[N],nn=1,b[N],mm;
int main(){
int i,j;
scanf("%d",&n);
for(i=1;i<=n;i++){scanf("%d",&a[i]);}
scanf("%d",&m);
if(m<=n){
printf("%d",a[m]);
}
else{
m=m-n;
std::sort(a+1,a+n+1);
for(i=2;i<=n;i++){
if(a[i-1]!=a[i]){
b[++nn]=a[i];
}
}
b[nn+1]=2100000000;
int g;
for(i=1;i<=n+1;i++){
if(b[i-1]<nn&&nn<=b[i]){
g=i;
break;
}
}
nn+=(m-1);
if(nn>=b[g]){
printf("%d",b[g]);
}
else{
printf("%d",nn);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
5 ms |
1472 KB |
Output is correct |
2 |
Correct |
1 ms |
1472 KB |
Output is correct |
3 |
Correct |
12 ms |
1472 KB |
Output is correct |
4 |
Correct |
1 ms |
1472 KB |
Output is correct |
5 |
Correct |
6 ms |
1472 KB |
Output is correct |
6 |
Correct |
9 ms |
1472 KB |
Output is correct |
7 |
Correct |
5 ms |
1472 KB |
Output is correct |
8 |
Correct |
1 ms |
1472 KB |
Output is correct |
9 |
Correct |
8 ms |
1472 KB |
Output is correct |
10 |
Correct |
13 ms |
1472 KB |
Output is correct |
11 |
Correct |
6 ms |
1472 KB |
Output is correct |
12 |
Correct |
0 ms |
1472 KB |
Output is correct |
13 |
Correct |
5 ms |
1472 KB |
Output is correct |
14 |
Correct |
5 ms |
1472 KB |
Output is correct |
15 |
Correct |
7 ms |
1472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1472 KB |
Output is correct |
2 |
Correct |
12 ms |
1472 KB |
Output is correct |
3 |
Correct |
9 ms |
1472 KB |
Output is correct |
4 |
Correct |
12 ms |
1472 KB |
Output is correct |
5 |
Correct |
4 ms |
1472 KB |
Output is correct |
6 |
Correct |
0 ms |
1472 KB |
Output is correct |
7 |
Correct |
9 ms |
1472 KB |
Output is correct |
8 |
Correct |
13 ms |
1472 KB |
Output is correct |
9 |
Correct |
3 ms |
1472 KB |
Output is correct |
10 |
Correct |
12 ms |
1472 KB |
Output is correct |
11 |
Correct |
2 ms |
1472 KB |
Output is correct |
12 |
Correct |
4 ms |
1472 KB |
Output is correct |
13 |
Incorrect |
0 ms |
1472 KB |
Output isn't correct |
14 |
Correct |
1 ms |
1472 KB |
Output is correct |
15 |
Correct |
7 ms |
1472 KB |
Output is correct |