# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867468 | 2023-10-28T12:49:16 Z | pizzamoeger | Zalmoxis (BOI18_zalmoxis) | C++14 | 112 ms | 19908 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) break; } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 94 ms | 10320 KB | Output is correct |
2 | Correct | 93 ms | 10328 KB | Output is correct |
3 | Correct | 94 ms | 10252 KB | Output is correct |
4 | Correct | 101 ms | 10324 KB | Output is correct |
5 | Correct | 98 ms | 10324 KB | Output is correct |
6 | Correct | 94 ms | 10312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 95 ms | 10336 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 98 ms | 10320 KB | Expected EOF |
3 | Incorrect | 112 ms | 10364 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 94 ms | 10320 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 109 ms | 10160 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 97 ms | 10324 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 97 ms | 10332 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 97 ms | 10308 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 106 ms | 11968 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 48 ms | 19908 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 66 ms | 14024 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 14 ms | 18124 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 13 ms | 18632 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 0 ms | 344 KB | Unexpected end of file - int32 expected |