# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59317 | 2018-07-21T13:54:12 Z | zubec | medians (balkan11_medians) | C++14 | 122 ms | 11432 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 508 KB | Output is correct |
4 | Correct | 3 ms | 748 KB | Output is correct |
5 | Correct | 3 ms | 860 KB | Output is correct |
6 | Correct | 3 ms | 956 KB | Output is correct |
7 | Correct | 2 ms | 956 KB | Output is correct |
8 | Correct | 3 ms | 956 KB | Output is correct |
9 | Correct | 2 ms | 956 KB | Output is correct |
10 | Correct | 2 ms | 1000 KB | Output is correct |
11 | Correct | 3 ms | 1000 KB | Output is correct |
12 | Correct | 2 ms | 1000 KB | Output is correct |
13 | Correct | 4 ms | 1164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1328 KB | Output is correct |
2 | Correct | 8 ms | 1500 KB | Output is correct |
3 | Correct | 9 ms | 2048 KB | Output is correct |
4 | Correct | 17 ms | 2784 KB | Output is correct |
5 | Correct | 46 ms | 4504 KB | Output is correct |
6 | Correct | 71 ms | 7968 KB | Output is correct |
7 | Correct | 122 ms | 11432 KB | Output is correct |