Submission #352469

# Submission time Handle Problem Language Result Execution time Memory
352469 2021-01-20T22:27:46 Z iliccmarko Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
1000 ms 35664 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())
        {
            sredi(s.top());
            v.pb({s.top(), 1});
            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 Incorrect 179 ms 12496 KB not a zalsequence
2 Incorrect 178 ms 12496 KB not a zalsequence
3 Incorrect 180 ms 12444 KB not a zalsequence
4 Incorrect 176 ms 12496 KB not a zalsequence
5 Incorrect 180 ms 12528 KB not a zalsequence
6 Incorrect 177 ms 12368 KB not a zalsequence
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 35448 KB Time limit exceeded
2 Incorrect 178 ms 12496 KB not a zalsequence
3 Execution timed out 1085 ms 35664 KB Time limit exceeded
4 Execution timed out 1048 ms 34896 KB Time limit exceeded
5 Execution timed out 1054 ms 34896 KB Time limit exceeded
6 Execution timed out 1087 ms 35536 KB Time limit exceeded
7 Execution timed out 1086 ms 35408 KB Time limit exceeded
8 Execution timed out 1043 ms 34740 KB Time limit exceeded
9 Execution timed out 1071 ms 34896 KB Time limit exceeded
10 Execution timed out 1067 ms 30812 KB Time limit exceeded
11 Execution timed out 1049 ms 32116 KB Time limit exceeded
12 Execution timed out 1080 ms 28140 KB Time limit exceeded
13 Execution timed out 1097 ms 28396 KB Time limit exceeded
14 Execution timed out 1093 ms 28012 KB Time limit exceeded