#include<bits/stdc++.h>
#define el '\n'
using namespace std ;
const int MN = 1e5 + 6;
int x[MN] , g[MN] , d[MN] , n;
namespace sub_trau{
void solve(){
int64_t ans = 0;
vector<int64_t> pref_gold(n + 5) , pref_en(n + 5);
for ( int i = 1 ; i <= n ; i++ ){
pref_gold[i] = pref_gold[i - 1] + g[i];
pref_en[i] = pref_en[i - 1] + d[i];
}
for ( int i = 1 ; i <= n ; i++ ){
for ( int j = i ; j <= n ; j++ ){
if (pref_en[i] - pref_en[j - 1] >= x[j] - x[i] + 1) ans = max(ans , pref_gold[i] - pref_gold[j - 1]);
}
}
cout << ans;
}
}
int32_t main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for ( int i = 1 ; i <= n ; i++ ) cin >> x[i] >> g[i] >> d[i];
if (n <= 5000) sub_trau::solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
504 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
504 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
504 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |