#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int x[N], g[N], d[N];
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> g[i] >> d[i];
}
long long curenergy = d[1], curgold = g[1], ans = 0;
int r = 2;
for(int i = 1; i <= n; i++){
while(r <= n && curenergy + d[r] >= x[r] - x[i]){
curenergy += d[r];
curgold += g[r];
r++;
}
ans = max(ans, curgold);
curenergy -= d[i];
curgold -= g[i];
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
376 KB |
Output is correct |
2 |
Correct |
15 ms |
504 KB |
Output is correct |
3 |
Correct |
18 ms |
480 KB |
Output is correct |
4 |
Correct |
85 ms |
888 KB |
Output is correct |
5 |
Correct |
102 ms |
1040 KB |
Output is correct |
6 |
Correct |
222 ms |
1516 KB |
Output is correct |
7 |
Correct |
149 ms |
1756 KB |
Output is correct |
8 |
Correct |
156 ms |
1696 KB |
Output is correct |
9 |
Correct |
144 ms |
1784 KB |
Output is correct |
10 |
Incorrect |
144 ms |
1784 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |