#include<stdio.h>
#include<map>
using namespace std;
int k,mini=2147483647,x[50010],n,ch[50010];
map<int,int >m;
int main()
{
int i,cnt=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&x[i]);
if(m[x[i]]==0) cnt++;
m[x[i]]=1;
}
for(i=1;i<=n;i++)
{
if(x[i]>=cnt && mini>x[i]) mini=x[i];
}
scanf("%d",&k);
if(k<=n) printf("%d",x[k]);
else if(mini==2147483647) printf("%d",k+cnt-n-1);
else if(k>=mini-cnt+1+n) printf("%d",mini);
else printf("%d",cnt+k-n-1);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1604 KB |
Output is correct |
2 |
Correct |
0 ms |
1604 KB |
Output is correct |
3 |
Correct |
0 ms |
1604 KB |
Output is correct |
4 |
Correct |
0 ms |
1604 KB |
Output is correct |
5 |
Correct |
0 ms |
1604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1604 KB |
Output is correct |
2 |
Correct |
0 ms |
1604 KB |
Output is correct |
3 |
Correct |
0 ms |
1604 KB |
Output is correct |
4 |
Correct |
0 ms |
1604 KB |
Output is correct |
5 |
Correct |
0 ms |
1604 KB |
Output is correct |
6 |
Correct |
0 ms |
1604 KB |
Output is correct |
7 |
Correct |
0 ms |
1604 KB |
Output is correct |
8 |
Correct |
0 ms |
1604 KB |
Output is correct |
9 |
Correct |
0 ms |
1604 KB |
Output is correct |
10 |
Correct |
0 ms |
1604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1604 KB |
Output is correct |
2 |
Correct |
4 ms |
1604 KB |
Output is correct |
3 |
Correct |
23 ms |
2132 KB |
Output is correct |
4 |
Correct |
0 ms |
1604 KB |
Output is correct |
5 |
Correct |
11 ms |
1604 KB |
Output is correct |
6 |
Correct |
3 ms |
1868 KB |
Output is correct |
7 |
Correct |
33 ms |
3848 KB |
Output is correct |
8 |
Correct |
0 ms |
1604 KB |
Output is correct |
9 |
Correct |
4 ms |
2000 KB |
Output is correct |
10 |
Correct |
0 ms |
1604 KB |
Output is correct |
11 |
Correct |
29 ms |
3056 KB |
Output is correct |
12 |
Correct |
5 ms |
2000 KB |
Output is correct |
13 |
Correct |
0 ms |
1604 KB |
Output is correct |
14 |
Correct |
33 ms |
3848 KB |
Output is correct |
15 |
Correct |
30 ms |
3584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1604 KB |
Output is correct |
2 |
Correct |
3 ms |
2000 KB |
Output is correct |
3 |
Correct |
28 ms |
3584 KB |
Output is correct |
4 |
Correct |
10 ms |
1604 KB |
Output is correct |
5 |
Correct |
38 ms |
3848 KB |
Output is correct |
6 |
Correct |
14 ms |
1604 KB |
Output is correct |
7 |
Correct |
0 ms |
1604 KB |
Output is correct |
8 |
Correct |
35 ms |
3848 KB |
Output is correct |
9 |
Correct |
3 ms |
1604 KB |
Output is correct |
10 |
Correct |
0 ms |
1604 KB |
Output is correct |
11 |
Correct |
22 ms |
2132 KB |
Output is correct |
12 |
Correct |
32 ms |
3056 KB |
Output is correct |
13 |
Correct |
0 ms |
1604 KB |
Output is correct |
14 |
Correct |
5 ms |
1604 KB |
Output is correct |
15 |
Correct |
2 ms |
1868 KB |
Output is correct |