#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#define all(a) a.begin() , a.end()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_multiset;
void solve()
{
int n;
cin >> n;
int a[n + 1] , b[n + 1] , c[n + 1] , d[n + 1] = {};
for(int i = 1 ; i <= n ; i++)
cin >> a[i] >> b[i] >> c[i] , d[i] = d[i - 1] + b[i];
int ans = 0;
for(int i = 1 ; i <= n ; i++)
{
int cur = 0 , po = 0;
for(int j = i ; j <= n ; j++)
{
po += c[j];
if(a[j] - a[i] <= po)
cur = d[j] - d[i - 1];
}
ans = max(ans , cur);
}
cout << ans << '\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
// cin >> t;
while(t--)
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |