이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include<bits/stdc++.h>
#define in freopen ("measurement.in", "r", stdin);
#define out freopen("measurement.out", "w", stdout);
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std ;
long long const N = 1e6 + 7;
long long N1 = 1e9 + 7;
int main( ){
//in out
speed ;
ll TJK = 1 ;
// cin >> TJK ;
while( TJK -- ){
ll n;
cin >> n;
ll a[n] , g[n] , d[n];
for( int i = 0 ; i < n ; i ++ ){
cin >> a[i] >> g[i] >> d[i];
}
ll g1[n] , d1[n];
g1[0] = g[0] , d1[0] = d[0];
for( int i = 1 ; i < n ; i ++ ){
g1[i] = g1[i-1] + g[i];
d1[i] = d1[i-1] + d[i];
}
ll l = 0 , r = 0 , go = 0 , di = 0 , en = 0 , mx = 0;
for( int i = 0 ; i < n ; i ++ ){
di = a[r] - a[l];
en = ( d1[r] - d1[l] ) + d[l];
go = ( g1[r] - g1[l] ) + g[l];
//cout << l << ' ' << r << ' ' << di << ' ' << en << ' ' << go << endl;
if( di <= en ){
r ++;
mx = max( mx , go );
}else{
while( di > en ){
l ++;
di = a[r] - a[l];
en = ( d1[r] - d1[l] ) + d[l];
go = ( g1[r] - g1[l] ) + g[l];
//cout << l << ' ' << r << ' ' << di << ' ' << en << ' ' << go << endl;
}
mx = max( mx , go );
r ++;
}
}
cout << mx << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |