Submission #647049

# Submission time Handle Problem Language Result Execution time Memory
647049 2022-10-01T13:24:30 Z LeonaRaging Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
108 ms 10112 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define ll long long
#define pb push_back
#define db(val) "[" #val " = " << (val) << "] "

const ll mod = 1e9 + 7;
const int maxn = 1e6 + 4;
const int INF = 1e9;

int n, k, a[maxn];
stack<int> st;
vector<int> myVec;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++) {
        while (!st.empty()) {
            if (st.top() < a[i])
                myVec.pb(st.top()), st.pop();
            else if (st.top() == a[i])
                st.pop(), a[i]++;
            else break;
        }
        st.push(a[i]);
    }
    while (!st.empty() && st.top() != 30) {
        int x = st.top(); st.pop();
        myVec.pb(x); st.push(x + 1);
    }
    int sz = myVec.size();
    vector<int> res;
    for (int i = 0; i < (int)myVec.size(); i++) {
        if (sz < n + k && myVec[i] > 1) {
            sz--;
            for (int j = max(1, myVec[i] - (n + k) + sz); j < myVec[i]; j++) {
                res.pb(j), sz++;
                if (sz == n + k) break;
            }
        }
        else res.pb(myVec[i]);
    }
    for (auto i : res) cout << i << ' ';
}
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 6248 KB Unexpected end of file - int32 expected
2 Incorrect 64 ms 6196 KB Unexpected end of file - int32 expected
3 Incorrect 69 ms 6164 KB Unexpected end of file - int32 expected
4 Incorrect 69 ms 6216 KB Unexpected end of file - int32 expected
5 Incorrect 66 ms 6236 KB Unexpected end of file - int32 expected
6 Incorrect 61 ms 6220 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 6196 KB Unexpected end of file - int32 expected
2 Incorrect 68 ms 6728 KB Unexpected end of file - int32 expected
3 Incorrect 81 ms 6944 KB Unexpected end of file - int32 expected
4 Incorrect 85 ms 6196 KB Unexpected end of file - int32 expected
5 Incorrect 65 ms 6220 KB Unexpected end of file - int32 expected
6 Incorrect 68 ms 6144 KB Unexpected end of file - int32 expected
7 Incorrect 66 ms 6220 KB Unexpected end of file - int32 expected
8 Incorrect 68 ms 6200 KB Unexpected end of file - int32 expected
9 Incorrect 108 ms 10112 KB Unexpected end of file - int32 expected
10 Incorrect 62 ms 5568 KB Unexpected end of file - int32 expected
11 Incorrect 104 ms 8128 KB Unexpected end of file - int32 expected
12 Incorrect 1 ms 340 KB Unexpected end of file - int32 expected
13 Incorrect 1 ms 332 KB Unexpected end of file - int32 expected
14 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected