#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;
int n, m, t;
int main()
{
#ifdef _CONSOLE
freopen("input.txt", "r", stdin);
#endif
int n;
cin >> n;
vector<int> vi(n);
for (int i = 0; i < n; i++){
cin >> vi[i];
}
cin >> m;
if (m <= n){
cout << vi[m - 1] << endl;
return 0;
}
sort(vi.begin(), vi.end());
vi.resize(unique(vi.begin(), vi.end()) - vi.begin());
vector<int>::iterator itor = lower_bound(vi.begin(), vi.end(), vi.size());
if (itor == vi.end()){
cout << (m - n) + (vi.size() - 1) << endl; // 무한
}
else{
if ((*itor - vi.size() + 1) + n <= m) // 아닐때
cout << *itor << endl;
else{
cout << (m - n) + (vi.size() - 1) << endl; // 무한
}
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
0 ms |
1720 KB |
Output isn't 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 |
Incorrect |
0 ms |
1720 KB |
Output isn't 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 |
25 ms |
1916 KB |
Output is correct |
2 |
Incorrect |
3 ms |
1720 KB |
Output isn't correct |
3 |
Correct |
2 ms |
1720 KB |
Output is correct |
4 |
Incorrect |
20 ms |
1916 KB |
Output isn't correct |
5 |
Correct |
16 ms |
1916 KB |
Output is correct |
6 |
Correct |
8 ms |
1720 KB |
Output is correct |
7 |
Correct |
5 ms |
1720 KB |
Output is correct |
8 |
Correct |
20 ms |
1916 KB |
Output is correct |
9 |
Correct |
23 ms |
1916 KB |
Output is correct |
10 |
Correct |
13 ms |
1916 KB |
Output is correct |
11 |
Correct |
13 ms |
1872 KB |
Output is correct |
12 |
Correct |
9 ms |
1880 KB |
Output is correct |
13 |
Correct |
11 ms |
1908 KB |
Output is correct |
14 |
Correct |
21 ms |
1916 KB |
Output is correct |
15 |
Incorrect |
4 ms |
1720 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
1872 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1720 KB |
Output isn't correct |
3 |
Correct |
15 ms |
1916 KB |
Output is correct |
4 |
Correct |
17 ms |
1908 KB |
Output is correct |
5 |
Correct |
0 ms |
1720 KB |
Output is correct |
6 |
Correct |
23 ms |
1916 KB |
Output is correct |
7 |
Correct |
10 ms |
1880 KB |
Output is correct |
8 |
Incorrect |
25 ms |
1916 KB |
Output isn't correct |
9 |
Correct |
7 ms |
1720 KB |
Output is correct |
10 |
Correct |
21 ms |
1916 KB |
Output is correct |
11 |
Correct |
26 ms |
1916 KB |
Output is correct |
12 |
Correct |
3 ms |
1720 KB |
Output is correct |
13 |
Incorrect |
24 ms |
1916 KB |
Output isn't correct |
14 |
Incorrect |
27 ms |
1916 KB |
Output isn't correct |
15 |
Incorrect |
5 ms |
1720 KB |
Output isn't correct |