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<map>
using namespace std;
int k,mini=2147483647,x[50010],n,ch[50010];
map<int,int >m;
int main()
{
int i,cnt=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&x[i]);
if(m[x[i]]==0) cnt++;
m[x[i]]=1;
}
for(i=1;i<=n;i++)
{
if(x[i]>=cnt && mini>x[i]) mini=x[i];
}
scanf("%d",&k);
if(k<=n) printf("%d",x[k]);
else if(mini==2147483647) printf("%d",k+cnt-n-1);
else if(k>=mini-cnt+1+n) printf("%d",mini);
else printf("%d",cnt+k-n-1);
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... |