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>
using namespace std;
struct gold {
int x, g, e;
} a[100001], pr[100001];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].g >> a[i].e;
pr[i].g = pr[i - 1].g + a[i].g;
pr[i].e = pr[i - 1].e + a[i].e;
}
sort (a + 1, a + 1 + n, [](gold a, gold b) -> bool {
if (a.x != b.x) return a.x < b.x;
if (a.e != b.e) return a.e > b.e;
return a.g >= b.g;
});
int ans = INT_MIN;
for (int left = 1; left <= n; left++) {
for (int right = left; right <= n; right++) {
if (a[right].x - a[left].x <= pr[right].e - pr[left - 1].e) {
ans = max(ans, pr[right].g - pr[left - 1].g);
}
}
}
cout << ans << '\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... |