Submission #1092096

# Submission time Handle Problem Language Result Execution time Memory
1092096 2024-09-23T07:19:17 Z juicy Divide and conquer (IZhO14_divide) C++17
100 / 100
60 ms 8816 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  const long long inf = 1e18;

  int n; cin >> n;
  set<array<long long, 2>> st;
  auto qry = [&](long long x) {
    auto it = st.upper_bound({x + 1, -inf});
    return it == st.begin() ? inf : (*prev(it))[1];
  };
  auto add = [&](long long x, long long y) {
    if (qry(x) <= y) {
      return;
    }
    auto it = st.insert({x, y}).first;
    for (++it; it != st.end(); it = st.erase(it)) {
      if ((*it)[1] < y) {
        break;
      }
    }
  };
  long long x = 0, y = 0, res = 0;
  while (n--) {
    int p, g, d; cin >> p >> g >> d;
    add(y - p, x);
    x += g, y += d;
    res = max(res, x - qry(y - p));
  }
  cout << res;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 624 KB Output is correct
24 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 624 KB Output is correct
24 Correct 3 ms 860 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 10 ms 1336 KB Output is correct
29 Correct 10 ms 1624 KB Output is correct
30 Correct 22 ms 3156 KB Output is correct
31 Correct 16 ms 1964 KB Output is correct
32 Correct 17 ms 2220 KB Output is correct
33 Correct 16 ms 1884 KB Output is correct
34 Correct 44 ms 4948 KB Output is correct
35 Correct 60 ms 8816 KB Output is correct
36 Correct 57 ms 8528 KB Output is correct