#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;
for ( int i = 1 ; i <= n ; i++ ){
for ( int j = i ; j <= n ; j++ ){
int64_t energy = 0 , gold = 0;
for ( int k = i ; k <= j ; k++ ){
energy += d[k];
gold += g[k];
}
if (energy >= x[j] - x[i]) ans = max(ans , gold);
}
}
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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
15 ms |
488 KB |
Output is correct |
16 |
Correct |
46 ms |
348 KB |
Output is correct |
17 |
Correct |
89 ms |
596 KB |
Output is correct |
18 |
Correct |
204 ms |
496 KB |
Output is correct |
19 |
Correct |
119 ms |
348 KB |
Output is correct |
20 |
Correct |
120 ms |
348 KB |
Output is correct |
21 |
Correct |
396 ms |
488 KB |
Output is correct |
22 |
Correct |
925 ms |
504 KB |
Output is correct |
23 |
Execution timed out |
1041 ms |
600 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
15 ms |
488 KB |
Output is correct |
16 |
Correct |
46 ms |
348 KB |
Output is correct |
17 |
Correct |
89 ms |
596 KB |
Output is correct |
18 |
Correct |
204 ms |
496 KB |
Output is correct |
19 |
Correct |
119 ms |
348 KB |
Output is correct |
20 |
Correct |
120 ms |
348 KB |
Output is correct |
21 |
Correct |
396 ms |
488 KB |
Output is correct |
22 |
Correct |
925 ms |
504 KB |
Output is correct |
23 |
Execution timed out |
1041 ms |
600 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |