Submission #780803

#TimeUsernameProblemLanguageResultExecution timeMemory
7808031binSnowball (JOI21_ho_t2)C++14
0 / 100
1 ms596 KiB
#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; assert(j <= n); ans[i] += mx[j]; ans[i + 1] += -mn[j]; if(j < n) { ll t = X[i + 1] - X[i] - mx[j] + mn[j]; assert(t > 0); ans[i + (W[j + 1] < 0)] += t; } } for(int i = 1; i <= n; i++) cout << ans[i] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...