Submission #488700

# Submission time Handle Problem Language Result Execution time Memory
488700 2021-11-20T06:15:10 Z SirCovidThe19th Divide and conquer (IZhO14_divide) C++17
100 / 100
116 ms 7192 KB
#include <bits/stdc++.h>
using namespace std;

const int mx = 1e5 + 5, msz = (1 << 17);

int n, X[mx]; long long G[mx], E[mx], seg[msz * 2], ans; 

void upd(int i, long long v){
    seg[i += msz] = v;
    for (i /= 2; i; i /= 2) seg[i] = min(seg[i * 2], seg[i * 2 + 1]); 
}
int qry(long long v){
    int i = 1; 
    while (i < msz) i = (seg[i * 2] <= v) ? i * 2 : i * 2 + 1;
    return i - msz;
}

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];
    }
    memset(seg, 0x3f, sizeof(seg)); 
    for (int i = 1; i <= n; i++){
        upd(i, E[i - 1] - X[i]);
        int pos = qry(E[i] - X[i]);
        ans = max(ans, G[i] - G[pos - 1]);
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2252 KB Output is correct
2 Correct 1 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 1 ms 2252 KB Output is correct
5 Correct 1 ms 2252 KB Output is correct
6 Correct 2 ms 2252 KB Output is correct
7 Correct 1 ms 2252 KB Output is correct
8 Correct 1 ms 2252 KB Output is correct
9 Correct 1 ms 2252 KB Output is correct
10 Correct 1 ms 2252 KB Output is correct
11 Correct 1 ms 2252 KB Output is correct
12 Correct 1 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2252 KB Output is correct
2 Correct 1 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 1 ms 2252 KB Output is correct
5 Correct 1 ms 2252 KB Output is correct
6 Correct 2 ms 2252 KB Output is correct
7 Correct 1 ms 2252 KB Output is correct
8 Correct 1 ms 2252 KB Output is correct
9 Correct 1 ms 2252 KB Output is correct
10 Correct 1 ms 2252 KB Output is correct
11 Correct 1 ms 2252 KB Output is correct
12 Correct 1 ms 2252 KB Output is correct
13 Correct 2 ms 2252 KB Output is correct
14 Correct 1 ms 2252 KB Output is correct
15 Correct 2 ms 2252 KB Output is correct
16 Correct 2 ms 2252 KB Output is correct
17 Correct 2 ms 2252 KB Output is correct
18 Correct 2 ms 2380 KB Output is correct
19 Correct 2 ms 2368 KB Output is correct
20 Correct 2 ms 2384 KB Output is correct
21 Correct 2 ms 2368 KB Output is correct
22 Correct 3 ms 2384 KB Output is correct
23 Correct 6 ms 2496 KB Output is correct
24 Correct 7 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2252 KB Output is correct
2 Correct 1 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 1 ms 2252 KB Output is correct
5 Correct 1 ms 2252 KB Output is correct
6 Correct 2 ms 2252 KB Output is correct
7 Correct 1 ms 2252 KB Output is correct
8 Correct 1 ms 2252 KB Output is correct
9 Correct 1 ms 2252 KB Output is correct
10 Correct 1 ms 2252 KB Output is correct
11 Correct 1 ms 2252 KB Output is correct
12 Correct 1 ms 2252 KB Output is correct
13 Correct 2 ms 2252 KB Output is correct
14 Correct 1 ms 2252 KB Output is correct
15 Correct 2 ms 2252 KB Output is correct
16 Correct 2 ms 2252 KB Output is correct
17 Correct 2 ms 2252 KB Output is correct
18 Correct 2 ms 2380 KB Output is correct
19 Correct 2 ms 2368 KB Output is correct
20 Correct 2 ms 2384 KB Output is correct
21 Correct 2 ms 2368 KB Output is correct
22 Correct 3 ms 2384 KB Output is correct
23 Correct 6 ms 2496 KB Output is correct
24 Correct 7 ms 2512 KB Output is correct
25 Correct 5 ms 2520 KB Output is correct
26 Correct 11 ms 2644 KB Output is correct
27 Correct 10 ms 2744 KB Output is correct
28 Correct 48 ms 4276 KB Output is correct
29 Correct 55 ms 4592 KB Output is correct
30 Correct 116 ms 7192 KB Output is correct
31 Correct 81 ms 6004 KB Output is correct
32 Correct 100 ms 6172 KB Output is correct
33 Correct 83 ms 5880 KB Output is correct
34 Correct 79 ms 5928 KB Output is correct
35 Correct 104 ms 6504 KB Output is correct
36 Correct 103 ms 6504 KB Output is correct