#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<int,pair<int,int>>> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i].first >> a[i].second.first >> a[i].second.second;
}
sort(a.begin() + 1, a.end());
int ans = 0;
for(int i = 1; i <= n; i++) {
int ce = 0;
int sum = 0;
for(int j = i; j <= n; j++) {
ce += a[j].second.second;
sum += a[j].second.first;
if(ce >= a[j].first - a[i].first) {
ans = max(ans, sum);
}
}
}
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... |