#include <stdio.h>
#include <vector>
#include <algorithm>
std::vector<int> arr;
int main()
{
std::vector<int>::iterator it;
int a, p, n, m, i;
scanf("%d", &n);
arr.reserve(n);
for(i=0;i<n;i++)
{
scanf("%d", &a);
arr.push_back(a);
}
scanf("%d", &m);
if(m<=n)
{
printf("%d", arr[m-1]);
return 0;
}
std::sort(arr.begin(), arr.end());
arr.erase(std::unique(arr.begin(), arr.end()), arr.end());
p=arr.size();
it=std::lower_bound(arr.begin(), arr.end(), p);
if(it==arr.end())
printf("%d", p+m-n-1);
else
printf("%d", std::min(p+m-n-1, *it));
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1580 KB |
Output is correct |
2 |
Correct |
0 ms |
1580 KB |
Output is correct |
3 |
Correct |
0 ms |
1580 KB |
Output is correct |
4 |
Correct |
0 ms |
1580 KB |
Output is correct |
5 |
Correct |
0 ms |
1580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1580 KB |
Output is correct |
2 |
Correct |
0 ms |
1580 KB |
Output is correct |
3 |
Correct |
0 ms |
1580 KB |
Output is correct |
4 |
Correct |
0 ms |
1580 KB |
Output is correct |
5 |
Correct |
0 ms |
1580 KB |
Output is correct |
6 |
Correct |
0 ms |
1580 KB |
Output is correct |
7 |
Correct |
0 ms |
1580 KB |
Output is correct |
8 |
Correct |
0 ms |
1580 KB |
Output is correct |
9 |
Correct |
0 ms |
1580 KB |
Output is correct |
10 |
Correct |
0 ms |
1580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1776 KB |
Output is correct |
2 |
Correct |
2 ms |
1580 KB |
Output is correct |
3 |
Correct |
3 ms |
1768 KB |
Output is correct |
4 |
Correct |
10 ms |
1776 KB |
Output is correct |
5 |
Correct |
6 ms |
1776 KB |
Output is correct |
6 |
Correct |
7 ms |
1732 KB |
Output is correct |
7 |
Correct |
5 ms |
1580 KB |
Output is correct |
8 |
Correct |
3 ms |
1580 KB |
Output is correct |
9 |
Correct |
2 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
1740 KB |
Output is correct |
11 |
Correct |
7 ms |
1776 KB |
Output is correct |
12 |
Correct |
3 ms |
1776 KB |
Output is correct |
13 |
Correct |
9 ms |
1776 KB |
Output is correct |
14 |
Correct |
12 ms |
1776 KB |
Output is correct |
15 |
Correct |
1 ms |
1580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
1776 KB |
Output is correct |
2 |
Correct |
3 ms |
1580 KB |
Output is correct |
3 |
Correct |
13 ms |
1776 KB |
Output is correct |
4 |
Correct |
14 ms |
1776 KB |
Output is correct |
5 |
Correct |
13 ms |
1776 KB |
Output is correct |
6 |
Correct |
0 ms |
1580 KB |
Output is correct |
7 |
Correct |
0 ms |
1580 KB |
Output is correct |
8 |
Correct |
14 ms |
1776 KB |
Output is correct |
9 |
Correct |
11 ms |
1776 KB |
Output is correct |
10 |
Correct |
9 ms |
1768 KB |
Output is correct |
11 |
Correct |
9 ms |
1776 KB |
Output is correct |
12 |
Correct |
0 ms |
1580 KB |
Output is correct |
13 |
Correct |
0 ms |
1740 KB |
Output is correct |
14 |
Correct |
0 ms |
1580 KB |
Output is correct |
15 |
Correct |
0 ms |
1732 KB |
Output is correct |