#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int sum[n]={0}, x[n], g[n], d[n];
for(int i=0; i<n; i++){
cin>>x[i]>>g[i]>>d[i];
}
sum[0]=g[0]; int mem=d[0];
for(int i=1; i<n; i++){
if(d[i] + mem >= x[i]) mem+=d[i], sum[i]=sum[i-1];
else mem=d[i];
sum[i]=sum[i]+g[i];
}
mem=sum[0];
for(int i=1; i<n; i++) mem=max(mem,sum[i]);
cout<<mem<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
356 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Incorrect |
3 ms |
252 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
380 KB |
Output is correct |
2 |
Correct |
14 ms |
588 KB |
Output is correct |
3 |
Incorrect |
17 ms |
632 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |