Submission #910116

# Submission time Handle Problem Language Result Execution time Memory
910116 2024-01-17T23:12:17 Z vjudge1 Snowball (JOI21_ho_t2) C++17
100 / 100
387 ms 13896 KB
#include <bits/stdc++.h>
using namespace std;

#define SIZE 200005
#define infl LLONG_MAX / 3

using ll = long long;

ll n, q, x[SIZE], ans[SIZE];
pair<ll, ll> t[SIZE];
int main(void) {
  cin >> n >> q;
  x[0] = -infl, x[n + 1] = infl;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 0; i <= n; i++) {
    t[i] = make_pair(x[i + 1] - x[i], i);
  }
  sort(t, t + n + 1);
  ll l = 0, r = 0, v = 0;
  int p = 0;
  while (q--) {
    ll w;
    cin >> w;
    if (w >= 0) {
      v += w;
      r = max(r, v);
      while (p <= n && t[p].first < l + r) {
        ans[t[p].second + 1] += l;
        ans[t[p].second] += t[p].first - l;
        p++;
      }
    } else {
      v += w;
      l = max(l, -v);
      while (p <= n && t[p].first < l + r) {
        ans[t[p].second] += r;
        ans[t[p].second + 1] += t[p].first - r;
        p++;
      }
    }
  }
  while (p <= n) {
    ans[t[p].second] += r;
    ans[t[p].second + 1] += l;
    p++;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 4 ms 2396 KB Output is correct
5 Correct 5 ms 2392 KB Output is correct
6 Correct 4 ms 2648 KB Output is correct
7 Correct 4 ms 2392 KB Output is correct
8 Correct 4 ms 2392 KB Output is correct
9 Correct 4 ms 2396 KB Output is correct
10 Correct 6 ms 2684 KB Output is correct
11 Correct 4 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 5 ms 2396 KB Output is correct
16 Correct 4 ms 2396 KB Output is correct
17 Correct 4 ms 2596 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 4 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 4 ms 2396 KB Output is correct
5 Correct 5 ms 2392 KB Output is correct
6 Correct 4 ms 2648 KB Output is correct
7 Correct 4 ms 2392 KB Output is correct
8 Correct 4 ms 2392 KB Output is correct
9 Correct 4 ms 2396 KB Output is correct
10 Correct 6 ms 2684 KB Output is correct
11 Correct 4 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 5 ms 2396 KB Output is correct
16 Correct 4 ms 2396 KB Output is correct
17 Correct 4 ms 2596 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 4 ms 2396 KB Output is correct
20 Correct 62 ms 4392 KB Output is correct
21 Correct 57 ms 4288 KB Output is correct
22 Correct 54 ms 4028 KB Output is correct
23 Correct 56 ms 3920 KB Output is correct
24 Correct 77 ms 6484 KB Output is correct
25 Correct 349 ms 11864 KB Output is correct
26 Correct 350 ms 11856 KB Output is correct
27 Correct 363 ms 11600 KB Output is correct
28 Correct 356 ms 11828 KB Output is correct
29 Correct 343 ms 11116 KB Output is correct
30 Correct 343 ms 10608 KB Output is correct
31 Correct 332 ms 9908 KB Output is correct
32 Correct 353 ms 10208 KB Output is correct
33 Correct 36 ms 5300 KB Output is correct
34 Correct 361 ms 12296 KB Output is correct
35 Correct 348 ms 11608 KB Output is correct
36 Correct 362 ms 12140 KB Output is correct
37 Correct 371 ms 11508 KB Output is correct
38 Correct 374 ms 11504 KB Output is correct
39 Correct 387 ms 11876 KB Output is correct
40 Correct 352 ms 11768 KB Output is correct
41 Correct 75 ms 5204 KB Output is correct
42 Correct 336 ms 10168 KB Output is correct
43 Correct 386 ms 13428 KB Output is correct
44 Correct 76 ms 4948 KB Output is correct
45 Correct 351 ms 11600 KB Output is correct
46 Correct 386 ms 13420 KB Output is correct
47 Correct 378 ms 13648 KB Output is correct
48 Correct 386 ms 13896 KB Output is correct