# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668180 | 2022-12-03T08:11:12 Z | 1zaid1 | Zalmoxis (BOI18_zalmoxis) | C++17 | 469 ms | 91004 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' const int M = 3e5+10; signed main() { cin.tie(0)->sync_with_stdio(0); int n, k; cin >> n >> k; vector<int> v(n), v1; for (int &i:v) cin >> i; map<int, int> vis; reverse(v.begin(), v.end()); vector<int> st; st.push_back(v.back()); v1 = {v.back()}; v.pop_back(); while (st.back() != 30) { if (v.empty()) { for (int i = st.back(); i < 30; i++) { k--; vis[v1.size()] = true; v1.push_back(i); } break; } else { int h = v.back(); int w = st.back(); if (h == w) { k--; vis[v1.size()] = true; v1.push_back(h); v.pop_back(); while (st.size() && h == w) { h = w+1; st.pop_back(); if (st.size()) w = st.back(); } st.push_back(h); } else if (h < w) { k--; v.pop_back(); st.push_back(h); vis[v1.size()] = true; v1.push_back(h); } else { v.push_back(w); } } } vector<int> ans; for (int i = 0; i < v1.size(); i++) { if (vis[i]&&k) { int l = v1[i]-1; for (int j = 1; l >= 0 && k > 1; j++, k--) { ans.push_back(l--); } k--; ans.push_back(l+1); } else ans.push_back(v1[i]); } for (int i:ans) cout << i << ' '; cout << endl; return 0; } /* 5 1 29 27 25 25 28 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 466 ms | 90796 KB | Expected EOF |
2 | Incorrect | 469 ms | 90804 KB | Expected EOF |
3 | Incorrect | 458 ms | 90820 KB | Expected EOF |
4 | Incorrect | 463 ms | 90804 KB | Expected EOF |
5 | Incorrect | 459 ms | 90952 KB | Expected EOF |
6 | Incorrect | 463 ms | 90848 KB | Expected EOF |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 466 ms | 90856 KB | Unexpected end of file - int32 expected |
2 | Correct | 454 ms | 90916 KB | Output is correct |
3 | Incorrect | 469 ms | 90928 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 447 ms | 90880 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 457 ms | 90788 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 468 ms | 90892 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 449 ms | 91004 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 451 ms | 90848 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 428 ms | 84512 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 211 ms | 41452 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 287 ms | 63060 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 1 ms | 212 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 1 ms | 212 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 0 ms | 212 KB | Unexpected end of file - int32 expected |