답안 #300772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300772 2020-09-17T13:23:25 Z kaplanbar Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
37 ms 2808 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1e5 + 5;
struct Element {
    int x, l, r;
    bool operator<(Element other) const {
        if(x == other.x) {
            return l > other.l;
        }
        return x > other.x;
    }
};
int n, k, a[N];
priority_queue<Element> q;
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    assert(k == 1);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        q.push((Element){a[i], i, i});
    }
    pair<int,int> Ans;
    while(1) {
        if(q.size() == 1) {
            assert(q.top().x == -30);
            break;
        }
        int mn = q.top().x;
        pair<int,int> le = make_pair(q.top().l, q.top().r);
        q.pop();
        if(mn == q.top().x && le.second == q.top().l - 1) {
            auto val = (Element){mn + 1, le.first, q.top().r};
            q.pop();
            q.push(val);
        }
        else {
            // Once we find the answer, we can stop searching
            // since it is guaranteed to have answer.
            Ans = make_pair(mn, le.second + 1);
            break;
        }
    }
    for(int i = 0; i < n + k; i++) {
        if(Ans.second == i) {
            cout << Ans.first << " ";
        }
        if(i < n) cout << a[i] << " ";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 2680 KB Unexpected end of file - int32 expected
2 Incorrect 19 ms 2808 KB Unexpected end of file - int32 expected
3 Incorrect 25 ms 2680 KB Unexpected end of file - int32 expected
4 Incorrect 23 ms 2680 KB Unexpected end of file - int32 expected
5 Incorrect 25 ms 2680 KB Unexpected end of file - int32 expected
6 Incorrect 37 ms 2680 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Runtime error 1 ms 512 KB Execution killed with signal 11
3 Runtime error 1 ms 512 KB Execution killed with signal 11
4 Runtime error 1 ms 512 KB Execution killed with signal 11
5 Runtime error 1 ms 512 KB Execution killed with signal 11
6 Runtime error 1 ms 512 KB Execution killed with signal 11
7 Runtime error 1 ms 512 KB Execution killed with signal 11
8 Runtime error 1 ms 512 KB Execution killed with signal 11
9 Runtime error 1 ms 512 KB Execution killed with signal 11
10 Runtime error 1 ms 512 KB Execution killed with signal 11
11 Runtime error 1 ms 512 KB Execution killed with signal 11
12 Runtime error 1 ms 512 KB Execution killed with signal 11
13 Runtime error 1 ms 512 KB Execution killed with signal 11
14 Runtime error 1 ms 512 KB Execution killed with signal 11