Submission #780804

# Submission time Handle Problem Language Result Execution time Memory
780804 2023-07-12T13:20:56 Z 1bin Snowball (JOI21_ho_t2) C++14
100 / 100
84 ms 16888 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 <= q);
        ans[i] += mx[j]; 
        ans[i + 1] += -mn[j];
        if(j < q) {
            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 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 400 KB Output is correct
4 Correct 1 ms 472 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 472 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 400 KB Output is correct
4 Correct 1 ms 472 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 472 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 21 ms 8684 KB Output is correct
21 Correct 24 ms 8668 KB Output is correct
22 Correct 18 ms 8260 KB Output is correct
23 Correct 18 ms 8152 KB Output is correct
24 Correct 22 ms 8704 KB Output is correct
25 Correct 76 ms 14932 KB Output is correct
26 Correct 82 ms 14876 KB Output is correct
27 Correct 74 ms 14712 KB Output is correct
28 Correct 70 ms 14668 KB Output is correct
29 Correct 69 ms 14252 KB Output is correct
30 Correct 67 ms 13556 KB Output is correct
31 Correct 55 ms 13088 KB Output is correct
32 Correct 42 ms 13188 KB Output is correct
33 Correct 7 ms 1876 KB Output is correct
34 Correct 73 ms 15288 KB Output is correct
35 Correct 84 ms 14684 KB Output is correct
36 Correct 72 ms 14924 KB Output is correct
37 Correct 72 ms 14768 KB Output is correct
38 Correct 71 ms 14536 KB Output is correct
39 Correct 72 ms 14792 KB Output is correct
40 Correct 52 ms 14700 KB Output is correct
41 Correct 21 ms 9212 KB Output is correct
42 Correct 45 ms 13440 KB Output is correct
43 Correct 52 ms 16456 KB Output is correct
44 Correct 21 ms 9196 KB Output is correct
45 Correct 50 ms 14700 KB Output is correct
46 Correct 64 ms 16592 KB Output is correct
47 Correct 62 ms 16880 KB Output is correct
48 Correct 56 ms 16888 KB Output is correct