#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define fi first
#define se second
#define LL long long
using namespace std;
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
int n;
int x[N];
LL g[N];
LL d[N];
LL pg[N];
LL pd[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
//freopen( "input.txt" , "r" , stdin );
//freopen( "output.txt" , "w" , stdout );
cin >> n;
LL ans = 0;
for( int i = 1; i <= n; i++ ){
cin >> x[i] >> g[i] >> d[i];
ans = max( ans , g[i] );
}
for( int i = 1; i <= n; i++ ){
pg[i] = pg[i - 1] + g[i];
pd[i] = pd[i - 1] + d[i];
}
for( int i = 1; i <= n; i++ ){
int l = i , r = n;
while( r - l > 3 ){
int m1 = l + (r - l) / 3;
int m2 = r - (r - l) / 2;
if( pd[m1] - pd[i - 1] <= x[m2] - x[i] ){
l = m1;
}
else r = m2;
}
for( ; l <= r; l++ ){
if( x[l] - x[i] <= pd[l] - pd[i - 1] ){
ans = max( ans , pg[l] - pg[i - 1] );
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |