Submission #352470

# Submission time Handle Problem Language Result Execution time Memory
352470 2021-01-20T22:36:25 Z iliccmarko Zalmoxis (BOI18_zalmoxis) C++14
35 / 100
1000 ms 34256 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define input(n, v) {for(int i = 0;i<n;i++) cin>>v[i];}
#define output(n, v) {for(int i = 0;i<n;i++) cout<<v[i]<<" "; cout<<endl;}
#define single_case solve();
#define line cout<<"------------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); }
int n, k;
stack<int> s;
vector<pair<int, int> > v;

void rastavi(int x)
{
    while(len(s)) s.pop();
    s.push(x);
    while(len(s)&&k)
    {
        int w = s.top();
        if(w==1) cout<<w<<" ";
        else
        {
            k--;
            s.push(w-1);
            s.push(w-1);
        }
    }
    while(len(s))
    {
        cout<<s.top()<<" ";
        s.pop();
    }
}

void sredi(int x)
{
    while(len(s)&&x==s.top())
    {
        s.pop();
        x++;
    }
    s.push(x);
}

int main()
{
    ios
    cin>>n>>k;
    for(int i = 1;i<=n+1;i++)
    {
        int x;
        if(i==n+1) x = 30;
        else cin>>x;
        while(len(s)&&x>s.top())
        {
            //cout<<s.top()<<" "<<x<<endl;
            v.pb({s.top(), 1});
            sredi(s.top());
            k--;
        }
        sredi(x);
        if(i<=n) v.pb({x, 0});
    }

    for(auto x : v)
    {
        if(x.second==0) cout<<x.first<<" ";
        else rastavi(x.first);
    }




    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 178 ms 10376 KB Output is correct
2 Correct 172 ms 10448 KB Output is correct
3 Correct 174 ms 10492 KB Output is correct
4 Correct 175 ms 10448 KB Output is correct
5 Correct 174 ms 10448 KB Output is correct
6 Correct 176 ms 10448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 33888 KB Time limit exceeded
2 Correct 180 ms 10448 KB Output is correct
3 Incorrect 173 ms 10448 KB Expected EOF
4 Execution timed out 1095 ms 34256 KB Time limit exceeded
5 Execution timed out 1091 ms 34128 KB Time limit exceeded
6 Execution timed out 1047 ms 32928 KB Time limit exceeded
7 Execution timed out 1098 ms 34128 KB Time limit exceeded
8 Execution timed out 1090 ms 34000 KB Time limit exceeded
9 Execution timed out 1042 ms 32976 KB Time limit exceeded
10 Execution timed out 1088 ms 31068 KB Time limit exceeded
11 Execution timed out 1054 ms 31568 KB Time limit exceeded
12 Execution timed out 1095 ms 28396 KB Time limit exceeded
13 Incorrect 203 ms 24444 KB Expected EOF
14 Execution timed out 1057 ms 27756 KB Time limit exceeded