Submission #991699

# Submission time Handle Problem Language Result Execution time Memory
991699 2024-06-02T19:54:32 Z VMaksimoski008 Divide and conquer (IZhO14_divide) C++17
100 / 100
72 ms 4692 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;

    vector<array<int, 3> > v(n+1);
    for(int i=1; i<=n; i++) cin >> v[i][0] >> v[i][1] >> v[i][2];
    ll P[n+1][3], ans = 0;;
    memset(P, 0, sizeof(P));
    for(int i=1; i<=n; i++)
        for(int j=1; j<3; j++) P[i][j] = P[i-1][j] + v[i][j];

    ll mn[n+1]; mn[0] = 1e18;
    for(int i=1; i<=n; i++) {
        mn[i] = min(mn[i-1], P[i-1][2] - v[i][0] + 1);

        int l=1, r=i, p=i;
        while(l <= r) {
            int mid = (l + r) / 2;
            if(mn[mid] <= P[i][2] - v[i][0]) p = mid, r = mid - 1;
            else l = mid + 1;
        }

        ans = max(ans, P[i][1] - P[p-1][1]);
    }

    cout << ans << '\n';
    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 0 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 0 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 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 0 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 0 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 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 444 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 4 ms 488 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 0 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 0 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 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 444 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 4 ms 488 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 4 ms 604 KB Output is correct
27 Correct 5 ms 604 KB Output is correct
28 Correct 29 ms 2564 KB Output is correct
29 Correct 33 ms 2384 KB Output is correct
30 Correct 72 ms 4692 KB Output is correct
31 Correct 52 ms 4684 KB Output is correct
32 Correct 53 ms 4684 KB Output is correct
33 Correct 48 ms 4692 KB Output is correct
34 Correct 54 ms 4688 KB Output is correct
35 Correct 58 ms 4680 KB Output is correct
36 Correct 61 ms 4692 KB Output is correct