답안 #680091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680091 2023-01-09T22:19:57 Z tvladm2009 Snowball (JOI21_ho_t2) C++14
100 / 100
119 ms 16920 KB
#include <bits/stdc++.h>
#define int ll

using ll = long long;

int const nmax = 200000;

int v[5 + nmax], aux[5 + nmax];
int sp[5 + nmax], mxl[5 + nmax], mxr[5 + nmax];
int sol[5 + nmax];

signed main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);

  int n, q;
  std::cin >> n >> q;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  for(int i = 1;i <= q; i++)
    std::cin >> aux[i];

  for(int i = 1;i <= q; i++) {
    sp[i] = sp[i - 1] + aux[i];
    mxl[i] = std::max(mxl[i - 1], -sp[i]);
    mxr[i] = std::max(mxr[i - 1], sp[i]);
  }
  for(int i = 1;i < n; i++) {
    int result = 0;
    for(int jump = (1 << 18); 0 < jump; jump /= 2)
      if(result + jump <= q && mxl[result + jump] + mxr[result + jump] < v[i + 1] - v[i])
        result += jump;
    result++;
    sol[i] += mxr[result - 1];
    sol[i + 1] += mxl[result - 1];
    if(result <= q) {
      if(aux[result] > 0)
        sol[i] += (v[i + 1] - v[i]) - (mxl[result - 1] + mxr[result - 1]);
      else
        sol[i + 1] += (v[i + 1] - v[i]) - (mxl[result - 1] + mxr[result - 1]);
    }
  }
  sol[1] += mxl[q];
  sol[n] += mxr[q];

  for(int i = 1;i <= n; i++)
    std::cout << sol[i] << "\n";
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 472 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 472 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 0 ms 328 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 472 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 472 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 0 ms 328 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 27 ms 8708 KB Output is correct
21 Correct 25 ms 8400 KB Output is correct
22 Correct 28 ms 8268 KB Output is correct
23 Correct 29 ms 8140 KB Output is correct
24 Correct 29 ms 8600 KB Output is correct
25 Correct 97 ms 14980 KB Output is correct
26 Correct 95 ms 14952 KB Output is correct
27 Correct 93 ms 14616 KB Output is correct
28 Correct 112 ms 14836 KB Output is correct
29 Correct 90 ms 14284 KB Output is correct
30 Correct 83 ms 13612 KB Output is correct
31 Correct 72 ms 12996 KB Output is correct
32 Correct 81 ms 13236 KB Output is correct
33 Correct 9 ms 1876 KB Output is correct
34 Correct 97 ms 15308 KB Output is correct
35 Correct 95 ms 14784 KB Output is correct
36 Correct 103 ms 14956 KB Output is correct
37 Correct 119 ms 14788 KB Output is correct
38 Correct 106 ms 14520 KB Output is correct
39 Correct 94 ms 14800 KB Output is correct
40 Correct 82 ms 14800 KB Output is correct
41 Correct 28 ms 9292 KB Output is correct
42 Correct 54 ms 13192 KB Output is correct
43 Correct 88 ms 16452 KB Output is correct
44 Correct 33 ms 9100 KB Output is correct
45 Correct 78 ms 14768 KB Output is correct
46 Correct 85 ms 16664 KB Output is correct
47 Correct 88 ms 16884 KB Output is correct
48 Correct 87 ms 16920 KB Output is correct