# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70017 | 2018-08-22T09:09:54 Z | gusfring | Zalmoxis (BOI18_zalmoxis) | C++14 | 349 ms | 10852 KB |
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; int n, k; vector<int> cur; vector<pii> ans; void upd () { while(cur.size() >= 2) { int A = cur.back(); cur.pop_back(); int B = cur.back(); cur.pop_back(); if(A != B) { cur.push_back(B); cur.push_back(A); return; } else cur.push_back(A+1); } } void print(int V) { if(V && k){ k--; print(V-1); print(V-1); } else{ printf("%d ",V); return; } } int main(){ scanf("%d%d",&n,&k); for(int i=1; i<=n; i++){ int T; scanf("%d",&T); while(!cur.empty() && T > cur.back()) { ans.push_back({cur.back(), 1}); k--; cur.push_back(cur.back()); upd(); } ans.push_back({T, 0}); cur.push_back(T); upd(); } while(cur[0] < 30) { ans.push_back({cur.back(), 1}); k--; cur.push_back(cur.back()); upd(); } for(auto &T : ans) { int A, B; tie(A, B) = T; if(B) print(A); else printf("%d ",A); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 262 ms | 10448 KB | Output is correct |
2 | Correct | 257 ms | 10448 KB | Output is correct |
3 | Correct | 264 ms | 10448 KB | Output is correct |
4 | Correct | 220 ms | 10548 KB | Output is correct |
5 | Correct | 253 ms | 10548 KB | Output is correct |
6 | Correct | 244 ms | 10644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 223 ms | 10644 KB | Output is correct |
2 | Correct | 349 ms | 10852 KB | Output is correct |
3 | Correct | 292 ms | 10852 KB | Output is correct |
4 | Correct | 317 ms | 10852 KB | Output is correct |
5 | Correct | 287 ms | 10852 KB | Output is correct |
6 | Correct | 288 ms | 10852 KB | Output is correct |
7 | Correct | 273 ms | 10852 KB | Output is correct |
8 | Correct | 273 ms | 10852 KB | Output is correct |
9 | Correct | 242 ms | 10852 KB | Output is correct |
10 | Correct | 172 ms | 10852 KB | Output is correct |
11 | Correct | 197 ms | 10852 KB | Output is correct |
12 | Correct | 103 ms | 10852 KB | Output is correct |
13 | Correct | 102 ms | 10852 KB | Output is correct |
14 | Correct | 96 ms | 10852 KB | Output is correct |