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<cstdio>
#include<algorithm>
#include<set>
int s[50001];
int b[5000000];
std::set<int> st;
int main()
{
int n,m,i;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&s[i]),b[i]=s[i],st.insert(s[i]);
std::set<int>::iterator k=st.upper_bound(st.size()-1);
scanf("%d",&m);
if(m<=n) printf("%d",b[m]);
else if(m<=n+(*k-st.size()+1)) printf("%d",m-n-1+st.size());
else printf("%d",*k);
return 0;
}
# | 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... |