# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
14014 | pjsdream | 이상한 수열 (OJUZ10_bizarre) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma warning(disable:4996)
#include <stdio.h>
#include <set>
using namespace std;
int n, m;
int a[50000];
set<int> s;
int main()
{
scanf("%d", &n);
for (int i=0; i<n; i++) scanf("%d", &a[i]), s.insert(a[i]);
scanf("%d", &m);
if (m<=n) {
printf("%d\n", a[m-1]);
}
else {
m -= n+1;
int b = s.size();
int e;
// B_n+1 = b
auto it = s.lower_bound(b);
if (it == s.end()) e = 2000000000;
else e = *it;
if (b+m <= e) printf("%d\n", b+m);
else printf("%d\n", e);
}
return 0;
}