답안 #756407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756407 2023-06-11T16:47:25 Z sheldon Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
152 ms 11284 KB
#include <bits/stdc++.h>

using namespace std;

void solve() {
    // ifstream cin ("zalmoxis.in");
    // ofstream cout ("zalmoxis.out");
    int n, k;
    cin >> n >> k;
    vector<int> st = {(int) 1e9};
    vector<int> a(n), ans;
    int done = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == st.back()) {
            st.push_back(a[i]);
            while (st.size() > 1 && st.back() == st[st.size() - 2]) {
                st.pop_back();
                st.back()++;
            }
        } else if (a[i] > st.back()) {
            while (a[i] >= st.back()) {
                ans.push_back(st.back());
                ++done;
                st.back()++;
                while (st.size() > 1 && st.back() == st[st.size() - 2]) {
                    st.pop_back();
                    st.back()++;
                }
            }
            --done;
            ans.pop_back();
        } else {
            st.push_back(a[i]);
        }
        ans.push_back(a[i]);
    }
    assert(st.size() >= 2);
    // while (st.size() != 2) {
    //     ans.push_back(st.back());
    //     st.push_back(st.back());
    //     ++done;
    //     while (st.size() > 1 && st.back() == st[st.size() - 2]) {
    //         st.pop_back();
    //         st.back()++;
    //     }
    // }
    for (int it = st[1]; it < st[1] + k - done; ++it) {
        ans.push_back(it);
    }
    for (int x : ans) cout << x << ' ';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 149 ms 10296 KB not a zalsequence
2 Incorrect 131 ms 10364 KB not a zalsequence
3 Incorrect 137 ms 10300 KB not a zalsequence
4 Incorrect 143 ms 10360 KB not a zalsequence
5 Incorrect 141 ms 10308 KB not a zalsequence
6 Incorrect 131 ms 10384 KB not a zalsequence
# 결과 실행 시간 메모리 Grader output
1 Incorrect 147 ms 10260 KB not a zalsequence
2 Incorrect 135 ms 10300 KB not a zalsequence
3 Incorrect 136 ms 10300 KB not a zalsequence
4 Incorrect 140 ms 10304 KB not a zalsequence
5 Incorrect 135 ms 10412 KB not a zalsequence
6 Incorrect 129 ms 10412 KB not a zalsequence
7 Incorrect 152 ms 10340 KB not a zalsequence
8 Incorrect 140 ms 10484 KB not a zalsequence
9 Incorrect 136 ms 9944 KB not a zalsequence
10 Incorrect 108 ms 10412 KB not a zalsequence
11 Incorrect 110 ms 10180 KB not a zalsequence
12 Incorrect 95 ms 11284 KB not a zalsequence
13 Incorrect 95 ms 11188 KB not a zalsequence
14 Incorrect 84 ms 11192 KB not a zalsequence