# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
780803 |
2023-07-12T13:20:19 Z |
1bin |
Snowball (JOI21_ho_t2) |
C++14 |
|
1 ms |
596 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;
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 time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
596 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |