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;
#define endl '\n'
#define ll long long
#define all(x) x.begin(), x.end()
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
set<int> notUsed;
for (int i = 1; i <= n * 2 - 1; i++) notUsed.insert(i);
vector<int> ans, a(n);
for (int i = 0; i < n; i++) cin >> a[i];
ans.push_back(a[0]);
notUsed.erase(a[0]);
for (int i = 1; i < n; i++) {
if (notUsed.count(a[i])) {
notUsed.erase(a[i]);
ans.push_back(a[i]);
int x = *notUsed.rbegin();
ans.push_back(x);
notUsed.erase(x);
}
else {
int x1 = *notUsed.begin(), x2 = *notUsed.rbegin();
ans.push_back(x1);
ans.push_back(x2);
notUsed.erase(x1);
notUsed.erase(x2);
}
}
for (auto x : ans) cout << x << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |