Submission #338959

#TimeUsernameProblemLanguageResultExecution timeMemory
338959MilosMilutinovicmedians (balkan11_medians)C++14
5 / 100
135 ms12908 KiB
#include <bits/stdc++.h> using namespace std; const int mxN=1e5; int n, a[mxN], ans[mxN*2]; set<int> b; int main() { cin >> n; for(int i=1; i<2*n; ++i) b.insert(i); for(int i=0; i<n; ++i) cin >> a[i], b.erase(a[i]); for(int i=0; i<n; ++i) if(i==0||a[i]!=a[i-1]) ans[2*i]=a[i]; for(int i=0; i<2*n-1; ++i) { if(ans[i]>0) continue; if(i%2==0) ans[i]=*b.begin(), b.erase(b.begin()); else { auto it=b.end(); --it; ans[i]=*it, b.erase(it); } } for(int i=0; i<2*n-1; ++i) cout << ans[i] << " "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...