#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 5e5;
signed main(){
int n;
cin >> n;
vector<vector<int>> a(n, vector<int>(3));
for(int i = 0; i < n; i++){
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
int mx2 = 0;
for(int i = 0; i < n; i++){
mx2 = max(mx2, a[i][1]);
}
for(int i = 1; i < n; i++){
a[i][1] += a[i - 1][1];
a[i][2] += a[i - 1][2];
}
int mx = 0;
int mx1 = 0;
for(int i = 0; i < n; i++){
if(a[i][2] >= a[i][0]){
mx1 = max(mx1, a[i][1]);
}
}
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
if(a[j][2] - a[i][2] >= a[j][0] - a[i][0]){
mx = max({mx, a[j][1] - a[j][1], a[i][1]});
}
}
}
cout << max({mx1, mx, mx2});
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |