이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |