제출 #344558

#제출 시각아이디문제언어결과실행 시간메모리
344558bachaquer금 캐기 (IZhO14_divide)C++14
17 / 100
1 ms384 KiB
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
 
using namespace std;
 
ll n, x, g, d;
 
struct lol {
    ll x;
    ll g;
    ll d;
};
 
int main() {
    //freopen("divide.in", "r", stdin);
    //freopen("divide.out", "w", stdout);
    cin >> n;
    vector<lol> v;
    vector<lol> khm;
    ll mx = -1;
    for (int i = 0; i < n; i++) {
        cin >> x >> g >> d;
        v.pb({x, g, d});
        khm = v;
        ll sum = 0;
        for (int j = i; j >= 0; j--) {
            sum += khm[j].g;
            if (j == 0 || khm[j - 1].d + khm[j].d < (khm[j].x - khm[j - 1].x)) break;
            else {
                khm[j].d -= (khm[j].x - khm[j - 1].x);
                if (khm[j].d < 0) {
                    khm[j - 1].d += khm[j].d;
                    khm[j].d = 0;
                }
            }
        }
        mx = max(mx, sum);
    }
    cout << mx;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...