# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340117 | 2020-12-27T00:00:09 Z | MilosMilutinovic | medians (balkan11_medians) | C++14 | 38 ms | 3200 KB |
#include <bits/stdc++.h> using namespace std; const int N=100050; int n,a[N],ans[N],mn,mx; bool was[2*N]; int down(){ while(was[mx])--mx; was[mx]=1; return mx; } int up(){ while(was[mn])++mn; was[mn]=1; return mn; } int main(){ scanf("%i",&n); for(int i=1;i<=n;i++)scanf("%i",&a[i]); ans[1]=a[1]; was[a[1]]=1; mn=0,mx=2*n; was[0]=1,was[2*n]=1; for(int i=2;i<=n;i++){ if(a[i]==a[i-1]){ ans[2*i-2]=down(); ans[2*i-1]=up(); }else{ if(a[i]>a[i-1]){ if(was[a[i]]){ ans[2*i-2]=down(); ans[2*i-1]=down(); }else{ ans[2*i-2]=a[i]; ans[2*i-1]=down(); } }else{ if(was[a[i]]){ ans[2*i-2]=up(); ans[2*i-1]=up(); }else{ ans[2*i-2]=a[i]; ans[2*i-1]=up(); } } } } for(int i=1;i<=2*n-1;i++)printf("%i ",ans[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Not a permutation |
3 | Incorrect | 1 ms | 364 KB | Not a permutation |
4 | Incorrect | 1 ms | 384 KB | Not a permutation |
5 | Incorrect | 1 ms | 364 KB | Not a permutation |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Incorrect | 1 ms | 384 KB | Not a permutation |
8 | Incorrect | 1 ms | 364 KB | Not a permutation |
9 | Incorrect | 1 ms | 376 KB | Not a permutation |
10 | Incorrect | 1 ms | 364 KB | Not a permutation |
11 | Incorrect | 1 ms | 364 KB | Not a permutation |
12 | Incorrect | 1 ms | 364 KB | Not a permutation |
13 | Incorrect | 1 ms | 364 KB | Not a permutation |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Not a permutation |
2 | Incorrect | 2 ms | 492 KB | Not a permutation |
3 | Incorrect | 3 ms | 620 KB | Not a permutation |
4 | Incorrect | 6 ms | 876 KB | Not a permutation |
5 | Incorrect | 12 ms | 1388 KB | Not a permutation |
6 | Incorrect | 23 ms | 2284 KB | Not a permutation |
7 | Incorrect | 38 ms | 3200 KB | Not a permutation |