#include <bits/stdc++.h>
using namespace std;
set<int> s;
int main() {
int n;
cin >> n;
for (int i = 1; i <= 2 * n - 1; i ++)
s.insert(i);
int x;
cin >> x;
s.erase(x);
cout << x << " ";
int last = x;
for (int i = 1; i < n; i ++) {
cin >> x;
if (s.count(x)) {
cout << x << " ";
s.erase(x);
if (last < x) {
cout << (*s.rbegin()) << " ";
s.erase(*s.rbegin());
} else {
cout << (*s.begin()) << " ";
s.erase(*s.begin());
}
} else {
if (last <= x) {
cout << (*s.rbegin()) << " ";
s.erase(*s.rbegin());
} else {
cout << (*s.begin()) << " ";
s.erase(*s.begin());
}
if (last < x) {
cout << (*s.rbegin()) << " ";
s.erase(*s.rbegin());
} else {
cout << (*s.begin()) << " ";
s.erase(*s.begin());
}
}
last = x;
}
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |