# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867470 | 2023-10-28T12:52:22 Z | pizzamoeger | Zalmoxis (BOI18_zalmoxis) | C++14 | 111 ms | 24520 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; } 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 | 94 ms | 10320 KB | Output is correct |
2 | Correct | 93 ms | 10320 KB | Output is correct |
3 | Correct | 111 ms | 10360 KB | Output is correct |
4 | Correct | 94 ms | 10240 KB | Output is correct |
5 | Correct | 102 ms | 10324 KB | Output is correct |
6 | Correct | 93 ms | 10320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 94 ms | 10212 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 92 ms | 10320 KB | Expected EOF |
3 | Incorrect | 93 ms | 10180 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 93 ms | 10320 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 92 ms | 10324 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 94 ms | 10320 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 94 ms | 10320 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 93 ms | 10332 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 91 ms | 11812 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 46 ms | 19396 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 64 ms | 14280 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 16 ms | 18816 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 13 ms | 17352 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 66 ms | 24520 KB | not a zalsequence |