#include <stdio.h>
#include <algorithm>
using namespace std;
int s[50001],b[50001];
int main (void)
{
int i,n,m,cnt=1,cnt2,mn=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&s[i]);
b[i]=s[i];
}
sort(b,b+n);
for(i=1;i<n;i++){
if(b[i-1]!=b[i])
cnt++;
}
scanf("%d",&m);
if(m<=n){
printf("%d\n",s[m-1]);
return 0;
}
cnt2=(m-n-1)+cnt;
for(i=0;i<n;i++){
if(cnt<=b[i] && b[i]<=cnt2){
if(mn==0)
mn=b[i];
else if(mn>b[i])
mn=b[i];
}
}
if(mn==0)
printf("%d\n",cnt2);
else
printf("%d\n",mn);
return 0;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1472 KB |
Output is correct |
2 |
Correct |
9 ms |
1472 KB |
Output is correct |
3 |
Correct |
0 ms |
1472 KB |
Output is correct |
4 |
Correct |
14 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 |
11 ms |
1472 KB |
Output is correct |
8 |
Correct |
9 ms |
1472 KB |
Output is correct |
9 |
Correct |
6 ms |
1472 KB |
Output is correct |
10 |
Correct |
6 ms |
1472 KB |
Output is correct |
11 |
Correct |
0 ms |
1472 KB |
Output is correct |
12 |
Correct |
0 ms |
1472 KB |
Output is correct |
13 |
Correct |
0 ms |
1472 KB |
Output is correct |
14 |
Correct |
10 ms |
1472 KB |
Output is correct |
15 |
Correct |
9 ms |
1472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 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 |
10 ms |
1472 KB |
Output is correct |
5 |
Correct |
4 ms |
1472 KB |
Output is correct |
6 |
Correct |
5 ms |
1472 KB |
Output is correct |
7 |
Correct |
0 ms |
1472 KB |
Output is correct |
8 |
Correct |
9 ms |
1472 KB |
Output is correct |
9 |
Correct |
0 ms |
1472 KB |
Output is correct |
10 |
Correct |
7 ms |
1472 KB |
Output is correct |
11 |
Correct |
15 ms |
1472 KB |
Output is correct |
12 |
Correct |
14 ms |
1472 KB |
Output is correct |
13 |
Correct |
12 ms |
1472 KB |
Output is correct |
14 |
Correct |
7 ms |
1472 KB |
Output is correct |
15 |
Correct |
0 ms |
1472 KB |
Output is correct |