Submission #714501

# Submission time Handle Problem Language Result Execution time Memory
714501 2023-03-24T20:25:24 Z Spade1 Safety (NOI18_safety) C++14
0 / 100
46 ms 6640 KB
#include<bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

priority_queue<ll> L, R;
ll offset_l, offset_r, ans, pos = -1e18;

void solve() {
    ll n, h; cin >> n >> h;
    for (int i = 1; i <= n; ++i) {
        ll a; cin >> a;
        offset_l -= h;
        offset_r += h;
        pos -= h;
        if (a >= pos) {
            R.push(-a+offset_r);
            R.push(-a+offset_r);
            L.push(-R.top()+offset_r-offset_l);
            R.pop();
            ans += a-L.top()-offset_l;
        }
        else {
            L.push(a-offset_l);
            L.push(a-offset_l);
            R.push(-L.top()-offset_l+offset_r);
            L.pop();
            ans += -R.top()+offset_r-a;
        }
        pos = L.top()+offset_l;
        cout << ans << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}

/*
6 1
2 10 0 2 4 3
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 6640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -