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 TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll ans=-inf;
ll n,x[maxN],g[maxN],d[maxN];
void solve()
{
cin >> n;
for(int i=1;i<=n;i++) cin >> x[i] >> g[i] >> d[i];
for(int i=1;i<=n;i++)
{
ll sum=g[i],re=d[i];
ans=max(ans,sum);
for(int j=i+1;j<=n;j++)
{
re+=d[j];
sum+=g[j];
if(re>=x[j]-x[i]) ans=max(ans,sum);
}
}
cout << ans;
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |