제출 #344576

#제출 시각아이디문제언어결과실행 시간메모리
344576mansurDivide and conquer (IZhO14_divide)C++14
48 / 100
1072 ms1260 KiB
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define ll long long
#define pb push_back
#define nl '\n'
#define popb pop_back()
#define sz size()
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define fix fixed<<setprecision
#define pii pair<int,int>
#define E exit (0)
#define int1 long long
const int inf=1e9;
int n,x[100001],g[100001],d[100001];
int main() {
	//freopen("planting.in","r",stdin);
	//freopen("planting.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for (int i=1;i<=n;i++) {
	 	cin>>x[i]>>g[i]>>d[i];
	}
	ll mx=0;
	for (int i=1;i<=n;i++) {
		ll gold=0,energy=0;
		for (int j=i;j<=n;j++) {
			energy+=d[j];
			gold+=g[j];
			if (x[j]-x[i]<=energy) {
				mx=max(mx,gold);
			}
		}
	}
	cout<<mx;
}
                                	
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...