# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
14685 | atomzeno | 이상한 수열 (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.
#include<stdio.h>
#include<algorithm>
#define N 100002
__int64 n,m,a[N],nn=1,b[N],mm;
int main(){
int i,j;
scanf("%I64d",&n);
for(i=1;i<=n;i++){scanf("%I64d",&a[i]);}
scanf("%I64d",&m);
if(m<=n){
printf("%d",a[m]);
}
else{
m=m-n;
std::sort(a+1,a+n+1);
for(i=2;i<=n;i++){
if(a[i-1]!=a[i]){
nn++;
b[nn]=a[i];
}
}
b[nn+1]=21000000000;
int g;
b[0]=-21000000000;
for(i=1;i<=nn+1;i++){
if(b[i-1]<nn&&nn<=b[i]){
g=i;
break;
}
}
nn+=(m-1);
if(nn>=b[g]){
printf("%I64d",b[g]);
}
else{
printf("%I64d",nn);
}
}
}