# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31725 | simotion | medians (balkan11_medians) | C++14 | 33 ms | 2600 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 <bits/stdc++.h>
using namespace std;
bool used[200005];
int inp[100000],n,li,hi;
int main() {
scanf("%d",&n);
li=1,hi=2*n-1;
for(int i=0;i<n;i++) scanf("%d",&inp[i]);
printf("%d ",inp[0]),used[inp[0]]=true;
for(int i=1;i<n;i++) {
if(inp[i-1]>=inp[i]) {
while(used[li]) li++;
printf("%d ",li),used[li]=true;
}
if(inp[i-1]<=inp[i]) {
while(used[hi]) hi--;
printf("%d ",hi),used[hi]=true;
}
if(inp[i-1]!=inp[i])
printf("%d ",inp[i]),used[inp[i]]=true;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |