# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59317 | zubec | medians (balkan11_medians) | C++14 | 122 ms | 11432 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>
using namespace std;
typedef long long ll;
typedef long double ld;
int n, b[100100];
vector <int> vec;
set<int> q;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
for (int i = 1; i < 2*n; i++)
q.insert(i);
for (int i = 1; i <= n; i++){
cin >> b[i];
if (i == 1){
vec.push_back(b[i]);
q.erase(b[i]);
continue;
}
if (b[i] == b[i-1]){
vec.push_back(*q.begin());
q.erase(q.begin());
vec.push_back(*prev(q.end()));
q.erase(prev(q.end()));
} else
if (b[i-1] < b[i]){
if (q.find(b[i]) == q.end()){
vec.push_back(*prev(q.end()));
q.erase(prev(q.end()));
vec.push_back(*prev(q.end()));
q.erase(prev(q.end()));
} else {
vec.push_back(b[i]);
q.erase(b[i]);
vec.push_back(*prev(q.end()));
q.erase(prev(q.end()));
}
} else {
if (q.find(b[i]) == q.end()){
vec.push_back(*q.begin());
q.erase(q.begin());
vec.push_back(*q.begin());
q.erase(q.begin());
} else {
vec.push_back(b[i]);
q.erase(b[i]);
vec.push_back(*q.begin());
q.erase(q.begin());
}
}
//break;
}
for (int i = 0; i < vec.size(); i++)
cout << vec[i] << ' ';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |