Submission #548609

# Submission time Handle Problem Language Result Execution time Memory
548609 2022-04-13T23:26:57 Z MilosMilutinovic Snowball (JOI21_ho_t2) C++14
100 / 100
500 ms 13816 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n, q;
  cin >> n >> q;
  vector<long long> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  vector<long long> mn(q + 1);
  vector<long long> mx(q + 1);
  long long bal = 0;
  for (int i = 0; i < q; i++) {
    long long w;
    cin >> w;
    bal += w;
    mn[i + 1] = min(mn[i], bal);
    mx[i + 1] = max(mx[i], bal);
  }
  x.push_back(1e18);
  vector<long long> R(n);
  for (int i = 0; i < n; i++) {
    long long low = x[i], high = min(x[i + 1], x[i] + mx[q]) + 1;
    while (low + 1 < high) {
      long long mid = (low + high) >> 1;
      int j = lower_bound(mx.begin(), mx.end(), mid - x[i]) - mx.begin();
      if (x[i + 1] + mn[j] >= mid) {
        low = mid;
      } else {
        high = mid;
      }
    }
    R[i] = low;
  }
  for (int i = 0; i < n; i++) {
    long long L = x[i] + mn[q];
    if (i > 0) {
     L = max(L, R[i - 1]);
    }
    cout << R[i] - L << '\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 340 KB Output is correct
4 Correct 3 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 420 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 424 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 4 ms 340 KB Output is correct
17 Correct 2 ms 372 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 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 340 KB Output is correct
4 Correct 3 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 420 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 424 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 4 ms 340 KB Output is correct
17 Correct 2 ms 372 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 26 ms 5492 KB Output is correct
21 Correct 25 ms 5364 KB Output is correct
22 Correct 26 ms 5108 KB Output is correct
23 Correct 30 ms 4980 KB Output is correct
24 Correct 68 ms 5496 KB Output is correct
25 Correct 484 ms 11828 KB Output is correct
26 Correct 500 ms 11784 KB Output is correct
27 Correct 381 ms 11384 KB Output is correct
28 Correct 459 ms 11544 KB Output is correct
29 Correct 368 ms 11112 KB Output is correct
30 Correct 199 ms 10540 KB Output is correct
31 Correct 60 ms 9924 KB Output is correct
32 Correct 67 ms 10024 KB Output is correct
33 Correct 39 ms 1488 KB Output is correct
34 Correct 406 ms 12200 KB Output is correct
35 Correct 438 ms 11544 KB Output is correct
36 Correct 467 ms 11892 KB Output is correct
37 Correct 428 ms 11564 KB Output is correct
38 Correct 440 ms 11392 KB Output is correct
39 Correct 431 ms 11812 KB Output is correct
40 Correct 174 ms 11568 KB Output is correct
41 Correct 31 ms 6128 KB Output is correct
42 Correct 53 ms 10028 KB Output is correct
43 Correct 133 ms 13412 KB Output is correct
44 Correct 32 ms 5984 KB Output is correct
45 Correct 170 ms 11688 KB Output is correct
46 Correct 152 ms 13492 KB Output is correct
47 Correct 145 ms 13768 KB Output is correct
48 Correct 81 ms 13816 KB Output is correct