# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
14215 | Fakeable | medians (balkan11_medians) | C++98 | 33 ms | 1312 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 chk[200200];
int main()
{
int n,front;
scanf("%d",&n);
int left=1, right=2*n-1;
scanf("%d",&front);
printf("%d ",front);
chk[front]=true;
int mid=front;
for(int i=1;i<n;i++) {
scanf("%d",&front);
if(!chk[front]) {
printf("%d ",front);
chk[front]=true;
if(front<mid) {
while(chk[left]) left++;
chk[left]=true;
printf("%d ",left);
}
else {
while(chk[right]) right--;
chk[right]=true;
printf("%d ",right);
}
}
else if(front==mid) {
while(chk[left]) left++;
while(chk[right]) right--;
chk[left]=chk[right]=true;
printf("%d %d ",left,right);
}
else if(front<mid) {
while(chk[left]) left++;
chk[left]=true;
printf("%d ",left);
while(chk[left]) left++;
chk[left]=true;
printf("%d ",left);
}
else {
while(chk[right]) right--;
chk[right]=true;
printf("%d ",right);
while(chk[right]) right--;
chk[right]=true;
printf("%d ",right);
}
mid=front;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |