이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |