# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
368443 | cpp219 | medians (balkan11_medians) | C++14 | 58 ms | 19564 KiB |
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>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 2e3 + 9;
const ll inf = 1e16 + 7;
typedef pair<int,int> LL;
vector<ll> ans;
set<ll> s;
ll n,b[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
cin>>n;
for (ll i = 1;i <= 2*n - 1;i++) s.insert(i);
for (ll i = 1;i <= n;i++) cin>>b[i],s.erase(b[i]);
ans.push_back(b[1]);
for (ll i = 2;i <= n;i++){
if (b[i] != b[i - 1]) ans.push_back(b[i]);
if (b[i - 1] >= b[i]) ans.push_back(*s.begin()),s.erase(s.begin());
if (b[i - 1] <= b[i]) ans.push_back(*prev(s.end())),s.erase(prev(s.end()));
}
for (auto i : ans) cout<<i<<" ";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |