# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
656473 | 2022-11-07T14:57:11 Z | MilosMilutinovic | Zalmoxis (BOI18_zalmoxis) | C++14 | 180 ms | 18356 KB |
#include <bits/stdc++.h> using namespace std; void Push(vector<int>& v) { while (v.size() >= 2) { int sz = (int) v.size(); if (v[sz - 1] == v[sz - 2]) { int x = v[sz - 1]; v.pop_back(); v.pop_back(); v.push_back(x + 1); } else { break; } } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } a.push_back(30); n++; vector<int> stk; vector<pair<int, int>> ans; for (int i = 0; i < n; i++) { while (!stk.empty() && stk.back() < a[i]) { int x = stk.back(); ans.emplace_back(stk.back(), 1); stk.push_back(stk.back()); Push(stk); } ans.emplace_back(a[i], 0); stk.push_back(a[i]); Push(stk); } ans.pop_back(); for (auto& p : ans) { cout << p.first << " "; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 140 ms | 18264 KB | Output is correct |
2 | Correct | 152 ms | 18356 KB | Output is correct |
3 | Correct | 166 ms | 18296 KB | Output is correct |
4 | Correct | 131 ms | 18168 KB | Output is correct |
5 | Correct | 149 ms | 18248 KB | Output is correct |
6 | Correct | 132 ms | 18236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 167 ms | 18236 KB | Unexpected end of file - int32 expected |
2 | Correct | 132 ms | 18268 KB | Output is correct |
3 | Incorrect | 148 ms | 18232 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 136 ms | 18252 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 180 ms | 18260 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 131 ms | 18244 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 149 ms | 18168 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 131 ms | 18164 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 120 ms | 16776 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 53 ms | 7744 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 81 ms | 12452 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 0 ms | 212 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 0 ms | 212 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 0 ms | 212 KB | Unexpected end of file - int32 expected |