This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define srt(x) sort( x.begin() , x.end() )
#define F first
#define S second
#define int ll
using namespace std;
const int N = 1e5 + 7 , MOD = 32768 , INF = 9e18 ;
int n , t , k , ans , sum , cnt , mx = -INF ;
int c[N] ;
int g[N] ;
int e[N] ;
signed main()
{
//freopen( ".in" , "r" , stdin ) ;
//freopen( ".out" , "w" , stdout ) ;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n ;
for ( int i = 0 ; i < n ; i++ )
{
cin >> c[i] >> g[i] >> e[i] ;
}
int l = 0 ;
for ( int r = 0 ; r < n ; r++ )
{
sum += g[r] ;
cnt += e[r] ;
while ( c[r] - c[l] > cnt && l < r )
{
sum -= g[l] ;
cnt -= e[l] ;
l++ ;
}
mx = max( sum , mx ) ;
}
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... |