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