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;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |