Submission #78388

# Submission time Handle Problem Language Result Execution time Memory
78388 2018-10-04T16:05:56 Z igzi Zalmoxis (BOI18_zalmoxis) C++17
100 / 100
298 ms 63896 KB
#include <bits/stdc++.h>
#define maxN 1000005

using namespace std;

int main(){
    std::ios::sync_with_stdio(false);
    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

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:28:25: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
         while(st.size() > 1 & st[0] == st[1]){
               ~~~~~~~~~~^~~
zalmoxis.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(res.size() < n+k){
           ~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 279 ms 33772 KB Output is correct
2 Correct 239 ms 33964 KB Output is correct
3 Correct 244 ms 33964 KB Output is correct
4 Correct 237 ms 33964 KB Output is correct
5 Correct 236 ms 33964 KB Output is correct
6 Correct 258 ms 33964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 235 ms 33980 KB Output is correct
2 Correct 280 ms 33980 KB Output is correct
3 Correct 256 ms 34064 KB Output is correct
4 Correct 237 ms 34064 KB Output is correct
5 Correct 247 ms 34064 KB Output is correct
6 Correct 245 ms 34064 KB Output is correct
7 Correct 238 ms 34180 KB Output is correct
8 Correct 298 ms 34180 KB Output is correct
9 Correct 253 ms 39980 KB Output is correct
10 Correct 267 ms 54512 KB Output is correct
11 Correct 264 ms 54512 KB Output is correct
12 Correct 278 ms 63724 KB Output is correct
13 Correct 260 ms 63724 KB Output is correct
14 Correct 277 ms 63896 KB Output is correct