Submission #780797

# Submission time Handle Problem Language Result Execution time Memory
780797 2023-07-12T13:15:33 Z 1bin Snowball (JOI21_ho_t2) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 2e5 + 5;
ll n, q, X[NMAX], W[NMAX], mn[NMAX], mx[NMAX], cur, v[NMAX], ans[NMAX];

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> q;
    for(int i = 1; i <= n; i++) cin >> X[i];
    for(int i = 1; i <= q; i++) {
        cin >> W[i];
        cur += W[i];
        mn[i] = min(mn[i - 1], cur);
        mx[i] = max(mx[i - 1], cur);
        v[i] = mx[i] - mn[i];
    }
    ans[1] += -mn[q];
    ans[n] += mx[q];
    for(int i = 1; i < n; i++){
        int j = lower_bound(v, v + q + 1, X[i + 1] - X[i]) - v - 1;
        ans[i] += mx[j]; 
        ans[i + 1] += -mn[j];
        if(j < n) {
            ll t = X[i + 1] - X[i] - mx[j] + mn[j];
            ans[i + (W[j + 1] < 0)] += t;
        }
    }
    for(int i = 1; i <= n; i++) cout << ans[i] << '\n';
    return 0;
} 
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -