#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 + 1){
G -= a[l].y;
E -= a[l].z;
l++;
}
if(l <= i && E >= a[i].x - a[l].x + 1){
mx = max(mx, G);
}
}
cout << mx;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |