| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 758357 | KN200711 | Divide and conquer (IZhO14_divide) | C++14 | 1 ms | 304 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	
	vector<int> x(N), y(N), z(N);
	for(int i=0;i<N;i++) scanf("%d %d %d", &x[i], &y[i], &z[i]);
	
	ll pref = 0ll;
	vector< pair<ll, ll> > as;
	as.clear();
	
	ll ans = 0ll, nw = 0ll;
	for(int i=0;i<N;i++) {
		if(as.size() == 0 || as.back().fi > pref - 1ll * x[i]) as.push_back(make_pair(-pref + 1ll * x[i], nw));
		nw += y[i];
		pref += z[i];
		
		ll ck = pref - x[i];
	//	cout<<ck<<endl;
		int P = lower_bound(as.begin(), as.end(), make_pair(-ck, 0ll)) - as.begin();
		ans = max(ans, nw - as[P].se);
	}
	printf("%lld\n", ans);
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
