Submission #488878

# Submission time Handle Problem Language Result Execution time Memory
488878 2021-11-20T17:47:51 Z SirCovidThe19th Divide and conquer (IZhO14_divide) C++17
100 / 100
130 ms 5268 KB
#include <bits/stdc++.h>
using namespace std;

const int mx = 1e5 + 5;

int n, X[mx]; long long G[mx], E[mx], pre[mx], ans; 

int main(){
    cin >> n; 
    for (int i = 1; i <= n; i++){
        cin >> X[i] >> G[i] >> E[i]; 
        G[i] += G[i - 1]; E[i] += E[i - 1];
        pre[i] = min(pre[i - 1], E[i - 1] - X[i]);
    }
    for (int i = 1; i <= n; i++){
        int L = 1, H = i;
        while (L < H){
            int M = (L + H) / 2;
            (pre[M] <= E[i] - X[i]) ? H = M : L = M + 1;
        }
        ans = max(ans, G[i] - G[L - 1]);
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 300 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
24 Correct 6 ms 540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 300 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
24 Correct 6 ms 540 KB Output is correct
25 Correct 3 ms 456 KB Output is correct
26 Correct 6 ms 588 KB Output is correct
27 Correct 9 ms 716 KB Output is correct
28 Correct 45 ms 2644 KB Output is correct
29 Correct 51 ms 2884 KB Output is correct
30 Correct 111 ms 5196 KB Output is correct
31 Correct 78 ms 4736 KB Output is correct
32 Correct 83 ms 4820 KB Output is correct
33 Correct 72 ms 4548 KB Output is correct
34 Correct 80 ms 4524 KB Output is correct
35 Correct 92 ms 5152 KB Output is correct
36 Correct 130 ms 5268 KB Output is correct