답안 #668200

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668200 2022-12-03T08:53:06 Z 1zaid1 Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
624 ms 101644 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

const int M = 3e5+10;

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int n, k;
    cin >> n >> k;

    vector<int> v(n), v1;
    for (int &i:v) cin >> i;
    vector<int> x;
for (int i:v) x.push_back(i);

    map<int, int> vis;
    reverse(v.begin(), v.end());
    vector<int> st; st.push_back(v.back());

    v1 = {v.back()};
    v.pop_back();
    while (st.back() != 30) {
        if (v.empty()) {
            for (int i = st.back(); i < 30; i++) {
                vis[v1.size()] = true;
                v1.push_back(i);
            }

            break;
        } else {
            int h = v.back();
            int w = st.back();

            if (h == w) {
                v1.push_back(h);
                v.pop_back();
                while (st.size() && h == w) {
                    h = w+1;
                    st.pop_back();
                    if (st.size()) w = st.back();
                } st.push_back(h);
            } else if (h < w) {
                v.pop_back();
                st.push_back(h);
                v1.push_back(h);
            } else {
                v.push_back(w);
            }
        }
    } swap(v, x);

    int j = 0;
    for (int i = 0; i < v.size(); i++) {
        while (v[i] != v1[j]) {
            vis[j] = 1, j++;
        }

        j++;
    }

    vector<int> ans;
    for (int i = 0; i < v1.size(); i++) {
        ans.push_back(v1[i]);
        k -= vis[i];
        if (vis[i]&&k>0) {
            while (ans.back()>0 && k > 0) {
                k--;
                ans.back()--;
                ans.push_back(ans.back());
            }
        }

        cout << k << endl;
    }

    // for (int j=0;j<v1.size();j++) cout << vis[j]; cout << endl;
    // for (int i:v) cout << i << ' '; cout << endl;
    // for (int i:v1) cout << i << ' '; cout << endl;
    for (int i:ans) cout << i << ' '; cout << endl;

    return 0;
}

/*
5 1
29 27 25 25 28

1 5
29
*/

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:56:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
zalmoxis.cpp:65:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (int i = 0; i < v1.size(); i++) {
      |                     ~~^~~~~~~~~~~
zalmoxis.cpp:82:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   82 |     for (int i:ans) cout << i << ' '; cout << endl;
      |     ^~~
zalmoxis.cpp:82:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   82 |     for (int i:ans) cout << i << ' '; cout << endl;
      |                                       ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 593 ms 98276 KB Expected EOF
2 Incorrect 624 ms 98432 KB Expected EOF
3 Incorrect 620 ms 98276 KB Expected EOF
4 Incorrect 604 ms 98328 KB Expected EOF
5 Incorrect 601 ms 98348 KB Expected EOF
6 Incorrect 592 ms 98256 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Incorrect 615 ms 99268 KB Expected EOF
2 Incorrect 459 ms 101156 KB Expected EOF
3 Incorrect 448 ms 101644 KB Expected EOF
4 Incorrect 577 ms 99184 KB Expected EOF
5 Incorrect 580 ms 98768 KB Expected EOF
6 Incorrect 601 ms 99324 KB Expected EOF
7 Incorrect 604 ms 99284 KB Expected EOF
8 Incorrect 610 ms 99372 KB Expected EOF
9 Incorrect 501 ms 98320 KB Expected EOF
10 Incorrect 266 ms 48320 KB Expected EOF
11 Incorrect 391 ms 74668 KB Expected EOF
12 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected