This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> V(N);
set<int> S;
for (int i=0; i<N; i++) {
cin >> V[i];
S.insert(V[i]);
}
int M;
cin >> M;
M --;
if (M < N) { cout << V[M] << endl; return 0; }
int sz = S.size();
S.insert(1999999999);
int last = *(S.lower_bound(sz));
M -= N;
cout << min(sz + M, last) << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |