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 ll long long
#define pb push_back
using namespace std;
ll n, x, g, d;
struct lol {
ll x;
ll g;
ll d;
};
int main() {
//freopen("divide.in", "r", stdin);
//freopen("divide.out", "w", stdout);
cin >> n;
vector<lol> v;
for (int i = 0; i < n; i++) {
cin >> x >> g >> d;
v.pb({x, g, d});
}
ll mx = -1;
for (int i = 0; i < n; i++) {
vector<lol> khm;
khm = v;
ll sum = 0;
for (int j = i; j < n; j++) {
sum += khm[j].g;
if (j == n - 1 || khm[j + 1].d + khm[j].d < (khm[j + 1].x - khm[j].x)) break;
else {
khm[j].d -= (khm[j + 1].x - khm[j].x);
if (khm[j].d < 0) {
khm[j + 1].d += khm[j].d;
khm[j].d = 0;
}
}
}
mx = max(mx, sum);
}
cout << mx;
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... |