답안 #696213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696213 2023-02-05T22:15:55 Z bdl Snowball (JOI21_ho_t2) C++17
100 / 100
113 ms 12184 KB
#include <iostream>
using namespace std;

const int N = 2e5, Q = 2e5;

int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  static long long x[N];
  for (int i = 0; i < n; i++)
    scanf("%lld", &x[i]);
  static long long mn[Q + 1], mx[Q + 1];
  long long c = 0;
  for (int i = 0; i < q; i++) {
    long long d;
    scanf("%lld", &d);
    c += d;
    mn[i + 1] = min(mn[i], c), mx[i + 1] = max(mx[i], c);
  }
  long long l = x[0] + mn[q];
  for (int i = 0; i < n - 1; i++) {
    int low = 1, hi = q;
    while (low < hi) {
      int t = (low + hi) / 2;
      if (x[i] + mx[t] >= x[i + 1] + mn[t])
        hi = t;
      else
        low = t + 1;
    }
    long long r = mn[low] == mn[low - 1] ? x[i + 1] + mn[low] : x[i] + mx[low];
    printf("%lld\n", min(x[i] + mx[q], r) - max(l, x[i] + mn[q]));
    l = r;
  }
  printf("%lld\n", x[n - 1] + mx[q] - max(l, x[n - 1] + mn[q]));
  return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld", &x[i]);
      |     ~~~~~^~~~~~~~~~~~~~~
Main.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%lld", &d);
      |     ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 ms 340 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 404 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 324 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 1 ms 340 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 404 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 27 ms 5564 KB Output is correct
21 Correct 36 ms 5332 KB Output is correct
22 Correct 24 ms 5104 KB Output is correct
23 Correct 23 ms 4976 KB Output is correct
24 Correct 29 ms 5248 KB Output is correct
25 Correct 103 ms 10360 KB Output is correct
26 Correct 96 ms 10188 KB Output is correct
27 Correct 113 ms 9828 KB Output is correct
28 Correct 104 ms 10100 KB Output is correct
29 Correct 94 ms 9456 KB Output is correct
30 Correct 92 ms 8876 KB Output is correct
31 Correct 71 ms 8308 KB Output is correct
32 Correct 63 ms 8508 KB Output is correct
33 Correct 10 ms 1332 KB Output is correct
34 Correct 99 ms 10592 KB Output is correct
35 Correct 99 ms 10092 KB Output is correct
36 Correct 99 ms 10196 KB Output is correct
37 Correct 101 ms 9960 KB Output is correct
38 Correct 95 ms 9824 KB Output is correct
39 Correct 99 ms 9992 KB Output is correct
40 Correct 73 ms 10068 KB Output is correct
41 Correct 42 ms 6068 KB Output is correct
42 Correct 63 ms 8464 KB Output is correct
43 Correct 75 ms 11836 KB Output is correct
44 Correct 27 ms 5932 KB Output is correct
45 Correct 70 ms 10016 KB Output is correct
46 Correct 74 ms 11916 KB Output is correct
47 Correct 90 ms 12156 KB Output is correct
48 Correct 82 ms 12184 KB Output is correct