제출 #685393

#제출 시각아이디문제언어결과실행 시간메모리
685393GudStonksDivide and conquer (IZhO14_divide)C++17
48 / 100
1069 ms2784 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ft first
#define sd second
const ll MOD = 1e9+7;
ll n;
vector<pair<ll, pair<ll, ll> > >q;

void fun(){
	cin>>n;
	for(int i = 1, a, b, c; i <= n; i++){
		cin>>a>>b>>c;
		q.push_back({a, {c, b}});
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		ll dist = 0, ch = q[i].sd.ft, sum = q[i].sd.sd;
		ans = max(ans, q[i].sd.sd);
		for(int j = i + 1; j < n; j++){
			dist += q[j].ft - q[j - 1].ft;
			ch += q[j].sd.ft;
			sum += q[j].sd.sd;
			if(dist <= ch)
				ans = max(ans, sum);
		}
	}
	cout<<ans<<endl;
}
int  main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ttt = 1;
	//cin>>ttt;
	while(ttt--)fun();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...