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>
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |