#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <queue>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <limits.h>
typedef long long ll;
using namespace std;
ll n, m, t;
int main()
{
#ifdef _CONSOLE
freopen("input.txt", "r", stdin);
#endif
ll n;
scanf("%d", &n);
vector<ll> vi(n);
for (ll i = 0; i < n; i++){
scanf("%d", &vi[i]);
}
scanf("%d", &m);
if (m <= n){
printf("%d\n", vi[m - 1]);
return 0;
}
sort(vi.begin(), vi.end());
vi.resize(unique(vi.begin(), vi.end()) - vi.begin());
vector<ll>::iterator itor = lower_bound(vi.begin(), vi.end(), vi.size());
if (itor == vi.end()){
printf("%lld\n", (m - n) + (vi.size() - 1)); // 무한
}
else{
if((*itor - vi.size() + 1) + n <= m) // 아닐때
printf("%lld\n", *itor);
else{
printf("%lld\n", (m - n) + (vi.size() - 1));
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1720 KB |
Output is correct |
2 |
Correct |
0 ms |
1720 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
0 ms |
1720 KB |
Output is correct |
5 |
Correct |
0 ms |
1720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1720 KB |
Output is correct |
2 |
Correct |
0 ms |
1720 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
0 ms |
1720 KB |
Output is correct |
5 |
Correct |
0 ms |
1720 KB |
Output is correct |
6 |
Correct |
0 ms |
1720 KB |
Output is correct |
7 |
Correct |
0 ms |
1720 KB |
Output is correct |
8 |
Correct |
0 ms |
1720 KB |
Output is correct |
9 |
Correct |
0 ms |
1720 KB |
Output is correct |
10 |
Correct |
0 ms |
1720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2020 KB |
Output is correct |
2 |
Correct |
3 ms |
1924 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
6 ms |
2112 KB |
Output is correct |
5 |
Correct |
6 ms |
2112 KB |
Output is correct |
6 |
Correct |
3 ms |
2096 KB |
Output is correct |
7 |
Correct |
1 ms |
1720 KB |
Output is correct |
8 |
Correct |
1 ms |
1720 KB |
Output is correct |
9 |
Correct |
5 ms |
2112 KB |
Output is correct |
10 |
Correct |
9 ms |
2112 KB |
Output is correct |
11 |
Correct |
0 ms |
1720 KB |
Output is correct |
12 |
Correct |
0 ms |
2112 KB |
Output is correct |
13 |
Correct |
6 ms |
2036 KB |
Output is correct |
14 |
Correct |
12 ms |
2112 KB |
Output is correct |
15 |
Correct |
0 ms |
2112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2036 KB |
Output is correct |
2 |
Correct |
13 ms |
2112 KB |
Output is correct |
3 |
Correct |
0 ms |
2096 KB |
Output is correct |
4 |
Correct |
1 ms |
1720 KB |
Output is correct |
5 |
Correct |
14 ms |
2112 KB |
Output is correct |
6 |
Correct |
14 ms |
2112 KB |
Output is correct |
7 |
Correct |
0 ms |
2112 KB |
Output is correct |
8 |
Correct |
14 ms |
2112 KB |
Output is correct |
9 |
Correct |
10 ms |
2112 KB |
Output is correct |
10 |
Correct |
5 ms |
1924 KB |
Output is correct |
11 |
Correct |
0 ms |
1720 KB |
Output is correct |
12 |
Correct |
13 ms |
2112 KB |
Output is correct |
13 |
Correct |
0 ms |
1720 KB |
Output is correct |
14 |
Correct |
3 ms |
1720 KB |
Output is correct |
15 |
Correct |
7 ms |
2020 KB |
Output is correct |