#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int low, high;
set<int> s;
int add_low(){
while (s.count(low))++low;
s.insert(low);
return low;
}
int add_high(){
while (s.count(high))--high;
s.insert(high);
return high;
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, prev, a;
cin>>n>>prev;
low=1, high=2*n-1;
s.insert(prev);
cout<<prev<<" ";
for (int i=1; i<n; ++i){
cin>>a;
if (a==prev)cout<<add_low()<<" "<<add_high()<<" ";
else if (s.count(a)){
if (a<prev)cout<<add_low()<<" "<<add_low()<<" ";
else cout<<add_high()<<" "<<add_high()<<" ";
}
else{
s.insert(a);
cout<<a<<" ";
if (a<prev)cout<<add_low()<<" ";
else cout<<add_high()<<" ";
}
prev=a;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |