Submission #866072

#TimeUsernameProblemLanguageResultExecution timeMemory
866072Blagojmedians (balkan11_medians)C++17
10 / 100
70 ms12160 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...