#include <stdio.h>
#include <vector>
#include <algorithm>
std::vector<int> arr;
int main()
{
int a, p, q, 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();
q=*std::lower_bound(arr.begin(), arr.end(), p);
printf("%d", std::min(p+m-n-1, q));
return 0;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1580 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1580 KB |
Output isn't 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 |
Incorrect |
0 ms |
1580 KB |
Output isn't correct |
7 |
Correct |
0 ms |
1580 KB |
Output is correct |
8 |
Incorrect |
0 ms |
1580 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
1580 KB |
Output isn't correct |
10 |
Correct |
0 ms |
1580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1776 KB |
Output isn't correct |
2 |
Correct |
7 ms |
1776 KB |
Output is correct |
3 |
Incorrect |
3 ms |
1580 KB |
Output isn't correct |
4 |
Correct |
0 ms |
1580 KB |
Output is correct |
5 |
Correct |
7 ms |
1776 KB |
Output is correct |
6 |
Correct |
0 ms |
1580 KB |
Output is correct |
7 |
Correct |
4 ms |
1776 KB |
Output is correct |
8 |
Correct |
2 ms |
1580 KB |
Output is correct |
9 |
Incorrect |
3 ms |
1740 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
1732 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
1776 KB |
Output isn't correct |
12 |
Correct |
1 ms |
1580 KB |
Output is correct |
13 |
Correct |
9 ms |
1776 KB |
Output is correct |
14 |
Correct |
4 ms |
1768 KB |
Output is correct |
15 |
Incorrect |
11 ms |
1776 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1580 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1776 KB |
Output isn't correct |
3 |
Correct |
7 ms |
1776 KB |
Output is correct |
4 |
Correct |
14 ms |
1776 KB |
Output is correct |
5 |
Correct |
16 ms |
1776 KB |
Output is correct |
6 |
Incorrect |
9 ms |
1768 KB |
Output isn't correct |
7 |
Incorrect |
13 ms |
1776 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
1740 KB |
Output isn't correct |
9 |
Correct |
0 ms |
1580 KB |
Output is correct |
10 |
Correct |
0 ms |
1580 KB |
Output is correct |
11 |
Incorrect |
0 ms |
1580 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
1732 KB |
Output isn't correct |
13 |
Incorrect |
12 ms |
1776 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
1580 KB |
Output isn't correct |
15 |
Incorrect |
13 ms |
1776 KB |
Output isn't correct |