#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
//freopen ("divide.in","r",stdin);
//freopen ("divide.out","w",stdout);
int n,x[100010],g[100010],d[100010],i,j,sg=0,sg1,s=0,s1,ans=0;
cin>>n;
for (i=0;i<n;i++)
{
cin>>x[i]>>g[i]>>d[i];
s+=d[i];
sg+=g[i];
}
for (i=0;i<n;i++)
{
s1=s;
sg1=sg;
for (j=n-1;j>=i;j--)
{
if (i==j || (x[j]-x[i]<=s1))
{
ans=max(ans,sg1);
}
s1-=d[j];
sg1-=g[j];
}
s-=d[i];
sg-=g[i];
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2760 KB |
Output is correct |
3 |
Correct |
0 ms |
2764 KB |
Output is correct |
4 |
Correct |
0 ms |
2764 KB |
Output is correct |
5 |
Correct |
0 ms |
2764 KB |
Output is correct |
6 |
Correct |
0 ms |
2764 KB |
Output is correct |
7 |
Correct |
0 ms |
2768 KB |
Output is correct |
8 |
Correct |
0 ms |
2764 KB |
Output is correct |
9 |
Correct |
0 ms |
2760 KB |
Output is correct |
10 |
Correct |
0 ms |
2760 KB |
Output is correct |
11 |
Correct |
0 ms |
2764 KB |
Output is correct |
12 |
Correct |
0 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2764 KB |
Output is correct |
2 |
Correct |
0 ms |
2760 KB |
Output is correct |
3 |
Correct |
1 ms |
2764 KB |
Output is correct |
4 |
Correct |
1 ms |
2768 KB |
Output is correct |
5 |
Incorrect |
1 ms |
2764 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
2768 KB |
Output is correct |
2 |
Correct |
125 ms |
2760 KB |
Output is correct |
3 |
Incorrect |
115 ms |
2764 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |