Submission #1028304

# Submission time Handle Problem Language Result Execution time Memory
1028304 2024-07-19T16:12:52 Z andrewp Divide and conquer (IZhO14_divide) C++14
100 / 100
26 ms 6316 KB
//Dedicated to my love, ivaziva
#include <bits/stdc++.h>
using namespace std;

#define ll int64_t
#define ar array

const int mxN=1e5+4;
ll n, x[mxN], g[mxN], e[mxN];
ll srch[mxN];

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

    cin >> n;
    for(int i=1; i<=n; ++i) {
        cin >> x[i] >> g[i] >> e[i];
    }
    for(int i=1; i<=n+3; ++i) {
        srch[i]=(ll)(-1e12);
    }
    for(int i=1; i<=n; ++i) {
        e[i]+=e[i-1];
        g[i]+=g[i-1];//umesto fenw
    }
    for(int i=n; i>=1; --i) srch[i]=max(srch[i+1], e[i]-x[i]);
    ll ans=0;
    for(int i=1; i<=n; ++i) {
        int lb=i, rb=n, slv=0;
        while(lb<=rb) {
            int mb=(lb+rb)/2;
            if(srch[mb]>=e[i-1]-x[i]) {
                lb=mb+1;
                slv=mb;
            }
            else {
                rb=mb-1;
            }
        }
        ans=max(ans, g[slv]-g[i-1]);
    }
    cout << ans << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 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 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 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 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 428 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 1 ms 348 KB Output is correct
20 Correct 1 ms 520 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 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 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 428 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 1 ms 348 KB Output is correct
20 Correct 1 ms 520 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 14 ms 2920 KB Output is correct
29 Correct 12 ms 3164 KB Output is correct
30 Correct 26 ms 6316 KB Output is correct
31 Correct 19 ms 5212 KB Output is correct
32 Correct 19 ms 5412 KB Output is correct
33 Correct 18 ms 5212 KB Output is correct
34 Correct 20 ms 5212 KB Output is correct
35 Correct 21 ms 5460 KB Output is correct
36 Correct 21 ms 5716 KB Output is correct