Submission #668172

# Submission time Handle Problem Language Result Execution time Memory
668172 2022-12-03T07:37:19 Z MrDeboo Zalmoxis (BOI18_zalmoxis) C++17
35 / 100
163 ms 15588 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    deque<int>a,b(n);
    for(auto &i:b)cin>>i;
    deque<int>dq={b[0]};
    a.push_back(b[0]);
    b.pop_front();
    while(b.size()){
        if(b[0]<=a.back()){
            a.push_back(b[0]);
            dq.push_back(b[0]);
            b.pop_front();
        }else{
            k--;
            a.push_back(a.back());
            dq.push_back(a.back());
        }
        while(a.size()>1&&a.back()==a[a.size()-2]){
            int A=a.back();
            a.pop_back();
            a.pop_back();
            a.push_back(A+1);
        }
    }
    while(a.size()>1){
        a.push_back(a.back());
        dq.push_back(a.back());
        k--;
        while(a.size()>1&&a.back()==a[a.size()-2]){
            int A=a.back();
            a.pop_back();
            a.pop_back();
            a.push_back(A+1);
        }
    }
    int g=a.back();
    while(k--){
        dq.push_back(g++);
    }
    for(auto &i:dq)cout<<i<<' ';
}
# Verdict Execution time Memory Grader output
1 Correct 130 ms 11188 KB Output is correct
2 Correct 142 ms 11200 KB Output is correct
3 Correct 130 ms 11140 KB Output is correct
4 Correct 141 ms 11288 KB Output is correct
5 Correct 129 ms 11160 KB Output is correct
6 Correct 128 ms 11220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 11144 KB not a zalsequence
2 Correct 145 ms 11156 KB Output is correct
3 Incorrect 129 ms 11160 KB not a zalsequence
4 Incorrect 163 ms 11248 KB not a zalsequence
5 Incorrect 135 ms 11212 KB not a zalsequence
6 Incorrect 127 ms 11196 KB not a zalsequence
7 Incorrect 137 ms 11228 KB not a zalsequence
8 Incorrect 129 ms 11136 KB not a zalsequence
9 Incorrect 123 ms 11252 KB not a zalsequence
10 Incorrect 94 ms 13484 KB not a zalsequence
11 Incorrect 102 ms 12440 KB not a zalsequence
12 Incorrect 73 ms 15440 KB not a zalsequence
13 Incorrect 74 ms 15320 KB not a zalsequence
14 Incorrect 80 ms 15588 KB not a zalsequence