Submission #894213

# Submission time Handle Problem Language Result Execution time Memory
894213 2023-12-28T02:56:10 Z box Snowball (JOI21_ho_t2) C++17
100 / 100
105 ms 12344 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);
      |     ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 1 ms 2560 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2508 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2500 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2492 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 1 ms 2488 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 1 ms 2560 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2508 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2500 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2492 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 1 ms 2488 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 20 ms 6616 KB Output is correct
21 Correct 32 ms 6588 KB Output is correct
22 Correct 19 ms 6224 KB Output is correct
23 Correct 19 ms 6228 KB Output is correct
24 Correct 34 ms 6316 KB Output is correct
25 Correct 97 ms 10360 KB Output is correct
26 Correct 100 ms 10332 KB Output is correct
27 Correct 97 ms 9892 KB Output is correct
28 Correct 87 ms 10128 KB Output is correct
29 Correct 85 ms 9552 KB Output is correct
30 Correct 105 ms 8892 KB Output is correct
31 Correct 65 ms 8480 KB Output is correct
32 Correct 82 ms 8528 KB Output is correct
33 Correct 12 ms 3372 KB Output is correct
34 Correct 97 ms 10536 KB Output is correct
35 Correct 100 ms 9980 KB Output is correct
36 Correct 95 ms 10404 KB Output is correct
37 Correct 89 ms 10140 KB Output is correct
38 Correct 86 ms 9968 KB Output is correct
39 Correct 81 ms 10120 KB Output is correct
40 Correct 91 ms 10204 KB Output is correct
41 Correct 40 ms 7252 KB Output is correct
42 Correct 66 ms 8620 KB Output is correct
43 Correct 71 ms 11772 KB Output is correct
44 Correct 23 ms 7176 KB Output is correct
45 Correct 58 ms 10068 KB Output is correct
46 Correct 62 ms 11972 KB Output is correct
47 Correct 63 ms 12232 KB Output is correct
48 Correct 63 ms 12344 KB Output is correct