#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
ll g[n+1]={};
ll d[n+1]={};
int x[n+1]={};
for(int i=1;i<=n;i++)
{
cin>>x[i]>>g[i]>>d[i];
g[i]+=g[i-1];
d[i]+=d[i-1];
}
int l=1;
ll ans=g[1];
for(int i=2;i<=n;i++)
{
if(x[i]-x[l]>d[i]-d[l-1])
{
while(l<i && x[i]-x[l]>d[i]-d[l-1])l++;
}
ans=max(ans,g[i]-g[l-1]);
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 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 |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 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 |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
504 KB |
Output is correct |
2 |
Correct |
13 ms |
632 KB |
Output is correct |
3 |
Correct |
18 ms |
760 KB |
Output is correct |
4 |
Correct |
85 ms |
2248 KB |
Output is correct |
5 |
Correct |
103 ms |
2632 KB |
Output is correct |
6 |
Correct |
220 ms |
5112 KB |
Output is correct |
7 |
Correct |
157 ms |
3960 KB |
Output is correct |
8 |
Correct |
156 ms |
4088 KB |
Output is correct |
9 |
Correct |
142 ms |
3832 KB |
Output is correct |
10 |
Incorrect |
145 ms |
3824 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |