#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);
}
for(ll i=1; i<=n; i++)
{
for(ll j=i+1; j<=n; j++)
{
ll energy=p[j]-p[i-1];
if(energy>=a[j]-a[i])
{
//cout<<i<<" "<<j<<" "<<s[i]<<" "<<s[j]<<endl;
ans=max(ans, s[j]-s[i-1]);
}
}
}
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 |
456 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
580 KB |
Output is correct |
5 |
Correct |
2 ms |
580 KB |
Output is correct |
6 |
Correct |
2 ms |
580 KB |
Output is correct |
7 |
Correct |
2 ms |
672 KB |
Output is correct |
8 |
Correct |
2 ms |
672 KB |
Output is correct |
9 |
Correct |
2 ms |
672 KB |
Output is correct |
10 |
Correct |
2 ms |
672 KB |
Output is correct |
11 |
Correct |
2 ms |
672 KB |
Output is correct |
12 |
Correct |
2 ms |
672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
672 KB |
Output is correct |
2 |
Correct |
2 ms |
672 KB |
Output is correct |
3 |
Correct |
2 ms |
672 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
672 KB |
Output is correct |
6 |
Correct |
3 ms |
724 KB |
Output is correct |
7 |
Correct |
3 ms |
724 KB |
Output is correct |
8 |
Correct |
3 ms |
732 KB |
Output is correct |
9 |
Correct |
3 ms |
752 KB |
Output is correct |
10 |
Correct |
4 ms |
824 KB |
Output is correct |
11 |
Correct |
13 ms |
1076 KB |
Output is correct |
12 |
Correct |
14 ms |
1284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1284 KB |
Output is correct |
2 |
Correct |
69 ms |
1312 KB |
Output is correct |
3 |
Correct |
60 ms |
1312 KB |
Output is correct |
4 |
Execution timed out |
1074 ms |
2208 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |