답안 #647062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647062 2022-10-01T13:38:16 Z LeonaRaging Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
117 ms 9612 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 (int i = 0; i < n + k; i++)
        cout << res[i] << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 62 ms 8396 KB Execution killed with signal 11
2 Runtime error 63 ms 8412 KB Execution killed with signal 11
3 Runtime error 62 ms 8340 KB Execution killed with signal 11
4 Runtime error 65 ms 8360 KB Execution killed with signal 11
5 Runtime error 61 ms 8376 KB Execution killed with signal 11
6 Runtime error 65 ms 8372 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 63 ms 8348 KB Execution killed with signal 11
2 Runtime error 68 ms 9192 KB Execution killed with signal 11
3 Runtime error 72 ms 9612 KB Execution killed with signal 11
4 Runtime error 62 ms 8384 KB Execution killed with signal 11
5 Runtime error 61 ms 8436 KB Execution killed with signal 11
6 Runtime error 62 ms 8396 KB Execution killed with signal 11
7 Runtime error 62 ms 8400 KB Execution killed with signal 11
8 Runtime error 63 ms 8328 KB Execution killed with signal 11
9 Incorrect 117 ms 8984 KB doesn't contain S as a subsequence
10 Runtime error 60 ms 8984 KB Execution killed with signal 11
11 Incorrect 105 ms 7304 KB doesn't contain S as a subsequence
12 Runtime error 3 ms 468 KB Execution killed with signal 11
13 Runtime error 2 ms 468 KB Execution killed with signal 11
14 Runtime error 2 ms 468 KB Execution killed with signal 11