Submission #59317

#TimeUsernameProblemLanguageResultExecution timeMemory
59317zubecmedians (balkan11_medians)C++14
100 / 100
122 ms11432 KiB
#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)

medians.cpp: In function 'int main()':
medians.cpp:58:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++)
                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...