Submission #1133781

#TimeUsernameProblemLanguageResultExecution timeMemory
1133781lopkusDivide and conquer (IZhO14_divide)C++20
48 / 100
1094 ms1604 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...