#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define st string
#define fr first
#define se second
const ll mod=1e9+7;
using namespace std;
ll p[100100], s[100100], n, a[100100];
int main()
{
//freopen("1.txt", "r", stdin);
//freopen("1.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
ll ans=0;
cin>>n;
for(ll i=1; i<=n; i++)
{
ll g, e;
cin>>a[i]>>g>>e;
p[i]=e+p[i-1];
s[i]=g+s[i-1];
ans=max(ans, g);
}
ll l=1, r=1;
while(r<=n)
{
while(p[r+1]-p[l-1]>=a[r+1]-a[l] && r+1<=n)
r++;
if(r==n && s[r]-s[l-1]<ans) break;
ans=max(ans, s[r]-s[l-1]);
l++;
}
cout<<ans;
return 0;
}
/*
4 6 3
1 2 1
2 4 1
2 3 2
3 1 4
1 4 3
3 4 10
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
408 KB |
Output is correct |
4 |
Correct |
2 ms |
408 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
644 KB |
Output is correct |
7 |
Correct |
2 ms |
644 KB |
Output is correct |
8 |
Correct |
2 ms |
644 KB |
Output is correct |
9 |
Correct |
2 ms |
644 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
2 ms |
644 KB |
Output is correct |
12 |
Correct |
2 ms |
644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
644 KB |
Output is correct |
2 |
Correct |
2 ms |
644 KB |
Output is correct |
3 |
Incorrect |
2 ms |
748 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
748 KB |
Output is correct |
2 |
Correct |
4 ms |
892 KB |
Output is correct |
3 |
Correct |
4 ms |
892 KB |
Output is correct |
4 |
Correct |
15 ms |
1824 KB |
Output is correct |
5 |
Correct |
18 ms |
1824 KB |
Output is correct |
6 |
Correct |
36 ms |
2940 KB |
Output is correct |
7 |
Correct |
26 ms |
2940 KB |
Output is correct |
8 |
Correct |
27 ms |
2940 KB |
Output is correct |
9 |
Correct |
26 ms |
2940 KB |
Output is correct |
10 |
Incorrect |
27 ms |
2940 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |