#include <bits/stdc++.h>
using namespace std;
#define lo long
int d[100003],j[100003];
int g[100003],ans,h[100003];
int x[100003],n;
int main(){std::ios::sync_with_stdio(false);
// ifstream cin("devide.in");
// ofstream cout("devide.out");
cin>>n;
for(int i=0;i<n;i++)
{
cin>>x[i]>>g[i]>>d[i];
j[i]=j[i-1]+d[i];
// cout<<j[i]<<" ";
h[i]=h[i-1]+g[i];
// cout<<h[i]<<endl;
}
for(int i=0;i<n;i++)
{
for(int q=i;q<n;q++)
{
// cout<<j[q]<<" "<<j[i]<<" "<<x[q]<<" "<<x[i]<<" +++++"<<endl;
if(j[q]-j[i-1]>=x[q]-x[i])
{
ans=max(ans,h[q]-h[i-1]);
}
}
}
cout<<ans<<endl;
}
/*
* *
* * * *
* * * *
* * * *
* * * *
* * *
* *
* *
* *
* *
* *
* *
* *
* *
*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4128 KB |
Output is correct |
2 |
Correct |
0 ms |
4128 KB |
Output is correct |
3 |
Correct |
0 ms |
4128 KB |
Output is correct |
4 |
Correct |
0 ms |
4128 KB |
Output is correct |
5 |
Correct |
0 ms |
4128 KB |
Output is correct |
6 |
Correct |
0 ms |
4128 KB |
Output is correct |
7 |
Correct |
0 ms |
4128 KB |
Output is correct |
8 |
Correct |
0 ms |
4128 KB |
Output is correct |
9 |
Correct |
0 ms |
4128 KB |
Output is correct |
10 |
Correct |
0 ms |
4128 KB |
Output is correct |
11 |
Correct |
0 ms |
4128 KB |
Output is correct |
12 |
Correct |
0 ms |
4128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4128 KB |
Output is correct |
2 |
Correct |
0 ms |
4128 KB |
Output is correct |
3 |
Correct |
0 ms |
4128 KB |
Output is correct |
4 |
Correct |
0 ms |
4128 KB |
Output is correct |
5 |
Incorrect |
0 ms |
4128 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
4128 KB |
Output is correct |
2 |
Correct |
113 ms |
4128 KB |
Output is correct |
3 |
Incorrect |
76 ms |
4128 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |