#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("divide.in", "r", stdin);
//freopen("divide.out", "w", stdout);
int n;
cin >> n;
int x[n] , g[n] , e[n] ;
for(int i=1; i<=n; i++){
cin >> x[i] >> g[i] >> e[i];
}
int rud = g[1];
int gold = g[1], energy = e[1];
for(int i=2; i<=n; i++){
int len = x[i] - x[i-1];
if(len <= energy + e[i]){
gold += g[i];
energy += e[i] - len;
}
else{
gold = g[i];
energy = e[i];
}
rud = max(rud, gold);
}
cout << gold;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |