# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74147 | admin | Zalmoxis (BOI18_zalmoxis) | C++17 | 415 ms | 62304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* 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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |