# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4900 | gs13068 | medians (balkan11_medians) | C++98 | 36 ms | 1408 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<cstdio>
bool exist[300000];
int main()
{
int l,r,bef;
int i,t,n;
scanf("%d",&n);
l=1;r=2*n-1;
scanf("%d",&t);
printf("%d",t);
exist[t]=true;
bef=t;
for(i=1;i<n;i++)
{
scanf("%d",&t);
if(!exist[t])
{
exist[t]=true;
printf(" %d",t);
if(t<bef)
{
while(exist[l])l++;
exist[l]=true;
printf(" %d",l);
}
else
{
while(exist[r])r--;
exist[r]=true;
printf(" %d",r);
}
}
else if(t==bef)
{
while(exist[l])l++;
exist[l]=true;
printf(" %d",l);
while(exist[r])r--;
exist[r]=true;
printf(" %d",r);
}
else if(t<bef)
{
while(exist[l])l++;
exist[l]=true;
printf(" %d",l);
while(exist[l])l++;
exist[l]=true;
printf(" %d",l);
}
else
{
while(exist[r])r--;
exist[r]=true;
printf(" %d",r);
while(exist[r])r--;
exist[r]=true;
printf(" %d",r);
}
bef=t;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |