# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336233 | 2020-12-15T03:15:17 Z | ttnhuy313 | Zalmoxis (BOI18_zalmoxis) | C++14 | 235 ms | 29488 KB |
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair <int, int> ii; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; int rem = n + k, x; stack <int> s, cur; stack <ii> ans; for(int i = 0; i < n; i++){ cin >> x; s.push(x); } cur.push(30); while (!s.empty()){ if (cur.top() <= s.top()){ ans.push(ii(cur.top(), cur.top() == s.top())); if (s.top() == cur.top()) s.pop(); cur.pop(); } else{ int x = cur.top(); cur.pop(); cur.push(x - 1); cur.push(x - 1); } } while (!cur.empty()) { ans.push(ii(cur.top(),0)); cur.pop(); } vector <int> fans; while (rem > 0){ if (ans.size() == rem || ans.top().second == 1 || ans.top().first==0){ fans.push_back(ans.top().first); ans.pop(); rem--; } else{ x = ans.top().first; ans.pop(); ans.push(ii(x - 1,0)); ans.push(ii(x - 1,0)); } } for(int i = 0; i < n + k; i++){ cout << fans[i] << " "; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 227 ms | 29432 KB | Output is correct |
2 | Correct | 192 ms | 29320 KB | Output is correct |
3 | Correct | 202 ms | 29448 KB | Output is correct |
4 | Correct | 208 ms | 29448 KB | Output is correct |
5 | Correct | 192 ms | 29448 KB | Output is correct |
6 | Correct | 225 ms | 29488 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 217 ms | 29360 KB | Output is correct |
2 | Correct | 198 ms | 29320 KB | Output is correct |
3 | Correct | 199 ms | 29392 KB | Output is correct |
4 | Correct | 211 ms | 29448 KB | Output is correct |
5 | Correct | 203 ms | 29448 KB | Output is correct |
6 | Correct | 235 ms | 29448 KB | Output is correct |
7 | Correct | 202 ms | 29444 KB | Output is correct |
8 | Correct | 197 ms | 29404 KB | Output is correct |
9 | Correct | 181 ms | 27908 KB | Output is correct |
10 | Correct | 158 ms | 18136 KB | Output is correct |
11 | Correct | 158 ms | 22236 KB | Output is correct |
12 | Correct | 115 ms | 10444 KB | Output is correct |
13 | Correct | 121 ms | 10316 KB | Output is correct |
14 | Correct | 141 ms | 10316 KB | Output is correct |