#include <bits/stdc++.h>
using namespace std;
using 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 ans = 0, totalG = 0, totalD = 0;
ll l = 0;
for (ll r = 0; r < n; ++r) {
totalG += g[r];
totalD += d[r];
while (l <= r && totalD < x[r] - x[l]) {
totalG -= g[l];
totalD -= d[l];
++l;
}
if (totalD >= x[r] - x[l])
ans = max(ans, totalG);
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |