제출 #1306229

#제출 시각아이디문제언어결과실행 시간메모리
1306229michael12금 캐기 (IZhO14_divide)C++20
17 / 100
1 ms580 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;
struct camp{
    int x, y, z;
};
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    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(l <= i && 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...