#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
ll n;
cin >> n;
vector<ll> x(n), g(n), d(n);
for (ll i = 0; i < n; ++i)
cin >> x[i] >> g[i] >> d[i];
ll left = 0, ans = 0, total_energy = 0, total_gold = 0;
for (ll right = 0; right < n; ++right) {
total_energy += d[right];
total_gold += g[right];
while (left <= right && total_energy < x[right] - x[left]) {
total_energy -= d[left];
total_gold -= g[left];
left++;
}
ans = max(ans, total_gold);
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |