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 <set>
using namespace std;
set<int> s;
int n;
int data[50010];
int main()
{
scanf("%d",&n);
int i;
for(i=1;i<=n;++i) scanf("%d",data+i);
int om,m;
scanf("%d",&m);
if(m<=n){
printf("%d\n",data[m]);
} else {
for(i=1;i<=n;++i) s.insert(data[i]);
m-=n+1;
set<int>::iterator it;
for(i=1;m;++i){
if(s.lower_bound(s.size())==s.end()){
break;
}
if(s.find(s.size()) != s.end()){
m=0;
break;
}
--m;
s.insert(s.size());
}
if(m){
printf("%d\n",s.size()+m);
} else printf("%d\n",s.size());
}
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... |