# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59797 | 2018-07-23T06:35:35 Z | model_code | Zalmoxis (BOI18_zalmoxis) | C++17 | 582 ms | 62464 KB |
/* lightly tested */ #include <cmath> #include <cassert> #include <iostream> #include <list> #include <deque> using namespace std; int main(){ int n, k; cin >> n >> k; deque<int> st; list<int> res; list<list<int>::iterator> increasable; int sum = 0; for(int i = 0; i <= n; ++i){ int x; if(i == n) x = 30; else cin >> x, sum += (1<<x); while(!st.empty() && st[0] < x){ res.push_back(st[0]); increasable.push_back(--res.end()); ++st[0]; while(st.size() > 1 && st[0] == st[1]){ st.pop_front(); ++st[0]; } } st.push_front(x); while(st.size() > 1 & st[0] == st[1]){ st.pop_front(); ++st[0]; } if(i != n) res.push_back(x); } while(res.size() < n+k){ auto it = increasable.front(); increasable.pop_front(); if(*it == 0) continue; --*it; increasable.push_back(it); increasable.push_back(res.insert(it, *it)); } for(auto x : res) cout << x << ' '; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 550 ms | 33748 KB | Output is correct |
2 | Correct | 511 ms | 33912 KB | Output is correct |
3 | Correct | 521 ms | 33980 KB | Output is correct |
4 | Correct | 537 ms | 33980 KB | Output is correct |
5 | Correct | 437 ms | 33980 KB | Output is correct |
6 | Correct | 460 ms | 34084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 568 ms | 34084 KB | Output is correct |
2 | Correct | 513 ms | 34084 KB | Output is correct |
3 | Correct | 477 ms | 34084 KB | Output is correct |
4 | Correct | 582 ms | 34084 KB | Output is correct |
5 | Correct | 432 ms | 34124 KB | Output is correct |
6 | Correct | 442 ms | 34124 KB | Output is correct |
7 | Correct | 570 ms | 34124 KB | Output is correct |
8 | Correct | 425 ms | 34124 KB | Output is correct |
9 | Correct | 515 ms | 40104 KB | Output is correct |
10 | Correct | 434 ms | 53952 KB | Output is correct |
11 | Correct | 385 ms | 53952 KB | Output is correct |
12 | Correct | 363 ms | 62376 KB | Output is correct |
13 | Correct | 533 ms | 62380 KB | Output is correct |
14 | Correct | 339 ms | 62464 KB | Output is correct |