# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867469 | 2023-10-28T12:50:29 Z | pizzamoeger | Zalmoxis (BOI18_zalmoxis) | C++14 | 120 ms | 21196 KB |
#include <bits/stdc++.h> #define int long long using namespace std; signed main () { cin.tie(0); ios_base::sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> S (n); for (int i = 0; i < n; i++) cin >> S[i]; stack<int> nums; vector<pair<int,int>> inserts; int i = 0; while (i < n) { int cur = S[i]; while (!nums.empty()) { int top = nums.top(); //cerr << cur << " " << top << " " << i << "\n"; if (cur == top) { cur++; nums.pop(); } else if (cur > top) { inserts.push_back({i, top}); cur = top+1; nums.pop(); i--; } else { nums.push(cur); break; } } if (nums.empty()) nums.push(cur); i++; } if (!nums.empty()) inserts.push_back({n, nums.top()}); int size = inserts.size(); int ind = 0; int ind2 = 0; while (inserts.size() < k) { inserts[ind].second--; inserts.push_back({inserts[ind]}); if (inserts[ind].second == 0) { ind2++; ind = ind2; } else ind = inserts.size()-1; if (ind2 == size) assert(false); } int j = 0; for (int i = 0; i < n; i++) { while (j < inserts.size() && i == inserts[j].first) { cout << inserts[j].second << " "; j++; } cout << S[i] << " "; } while (j < inserts.size() && n == inserts[j].first) { cout << inserts[j].second << " "; j++; } cout << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 92 ms | 10320 KB | Output is correct |
2 | Correct | 120 ms | 10348 KB | Output is correct |
3 | Correct | 95 ms | 10324 KB | Output is correct |
4 | Correct | 94 ms | 10320 KB | Output is correct |
5 | Correct | 93 ms | 10320 KB | Output is correct |
6 | Correct | 97 ms | 10340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 55 ms | 16476 KB | Execution killed with signal 6 |
2 | Incorrect | 98 ms | 10296 KB | Expected EOF |
3 | Incorrect | 93 ms | 10316 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 95 ms | 10320 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 94 ms | 10320 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 93 ms | 10320 KB | Unexpected end of file - int32 expected |
7 | Runtime error | 59 ms | 16460 KB | Execution killed with signal 6 |
8 | Runtime error | 62 ms | 16460 KB | Execution killed with signal 6 |
9 | Incorrect | 89 ms | 12236 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 48 ms | 21196 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 70 ms | 13868 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 15 ms | 17100 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 14 ms | 18892 KB | Unexpected end of file - int32 expected |
14 | Runtime error | 1 ms | 604 KB | Execution killed with signal 6 |