# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
756468 | 2023-06-11T17:38:51 Z | sheldon | Zalmoxis (BOI18_zalmoxis) | C++14 | 211 ms | 11336 KB |
#include <bits/stdc++.h> using namespace std; void solve() { // ifstream cin ("zalmoxis.in"); // ofstream cout ("zalmoxis.out"); int n, k; cin >> n >> k; vector<int> st = {(int) 1e9}; vector<int> a(n), ans; int done = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; assert(a[i] <= 1e9); if (a[i] == st.back()) { st.push_back(a[i]); while (st.size() > 1 && st.back() == st[st.size() - 2]) { st.pop_back(); st.back()++; } } else if (a[i] > st.back()) { while (a[i] > st.back()) { ans.push_back(st.back()); st.push_back(st.back()); ++done; while (st.size() > 1 && st.back() == st[st.size() - 2]) { st.pop_back(); st.back()++; } } st.push_back(a[i]); while (st.size() > 1 && st.back() == st[st.size() - 2]) { st.pop_back(); st.back()++; } } else { st.push_back(a[i]); } ans.push_back(a[i]); } while (st.size() != 2) { ans.push_back(st.back()); st.push_back(st.back()); ++done; while (st.size() > 1 && st.back() == st[st.size() - 2]) { st.pop_back(); st.back()++; } } for (int it = st[1]; it < st[1] + k - done; ++it) { ans.push_back(it); } st.clear(); for (int i = 0; i < ans.size(); ++i) { st.push_back(ans[i]); while (st.size() > 1 && st.back() == st[st.size() - 2]) { st.pop_back(); st.back()++; } } assert(st.size() == 1); for (int x : ans) cout << x << ' '; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 150 ms | 10356 KB | Output is correct |
2 | Correct | 179 ms | 10328 KB | Output is correct |
3 | Correct | 151 ms | 10388 KB | Output is correct |
4 | Correct | 147 ms | 10464 KB | Output is correct |
5 | Correct | 197 ms | 10300 KB | Output is correct |
6 | Correct | 150 ms | 10320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 147 ms | 10256 KB | not a zalsequence |
2 | Correct | 152 ms | 10380 KB | Output is correct |
3 | Incorrect | 146 ms | 10448 KB | not a zalsequence |
4 | Incorrect | 169 ms | 10428 KB | not a zalsequence |
5 | Incorrect | 152 ms | 10300 KB | not a zalsequence |
6 | Incorrect | 147 ms | 10292 KB | not a zalsequence |
7 | Incorrect | 150 ms | 10360 KB | not a zalsequence |
8 | Incorrect | 211 ms | 10300 KB | not a zalsequence |
9 | Incorrect | 134 ms | 9820 KB | not a zalsequence |
10 | Incorrect | 104 ms | 10320 KB | not a zalsequence |
11 | Incorrect | 113 ms | 9916 KB | not a zalsequence |
12 | Incorrect | 114 ms | 11336 KB | not a zalsequence |
13 | Incorrect | 85 ms | 11232 KB | not a zalsequence |
14 | Incorrect | 84 ms | 11184 KB | not a zalsequence |