#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define fi first
#define se second
const int MAXN = 5010;
pair <ll, pll> arr[MAXN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> arr[i].fi >> arr[i].se.fi >> arr[i].se.se;
ll rj = 0;
for (int i = 0; i < n; i++) {
ll zb = 0, gold = 0;
for (int j = i; j < n; j++) {
zb += arr[j].se.se;
gold += arr[j].se.fi;
if (zb >= arr[j].fi - arr[i].fi) rj = max(rj, gold);
}
}
cout << rj << "\n";
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... |