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 db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define int long long
using namespace std;
const int N = 5e3 + 3;
int n, x[N], d[N], g[N];
int pd[N], pg[N], ans;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for (int i = 1; i <= n; i++) {
cin>>x[i]>>g[i]>>d[i];
pd[i] = pd[i - 1] + d[i];
pg[i] = pg[i - 1] + g[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (pd[i] - pd[j - 1] >= x[i] - x[j]) {
ans = max(ans, pg[i] - pg[j - 1]);
}
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |