제출 #1305812

#제출 시각아이디문제언어결과실행 시간메모리
1305812michael12금 캐기 (IZhO14_divide)C++20
17 / 100
1 ms576 KiB
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
const int maxn = 5e5;
struct camp{
    int x, y, z;
};
signed main(){
    int n;
    cin >> n;
    vector<camp> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].x >> a[i].y >> a[i].z;
    }
    int E = 0;
    int G = 0;
    int l = 0;
    int mx = 0;
    for(int i = 0; i < n; i++){
        G += a[i].y;
        E += a[i].z;
        while(l <= i && E < a[i].x - a[l].x){
             G -= a[l].y;
             E -= a[l].z;
             l++;
        }
        if(E >= a[i].x - a[l].x){
            mx = max(mx, G);
        }

    }
    cout << mx;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...