#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll gold[maxn], energy[maxn], x[maxn], n;
ll prefix_g[maxn], prefix_e[maxn];
int main() {
cin>>n;
for(int i=1;i<=n;i++) {
cin>>x[i]>>gold[i]>>energy[i];
prefix_g[i] = prefix_g[i-1] + gold[i];
prefix_e[i] = prefix_e[i-1] + energy[i];
}
ll result = 0LL;
for(int i=1;i<=n;i++) {
for(int j=i;j>=1;j--) {
if(x[i] - x[j] <= prefix_e[i] - prefix_e[j-1]) {
result = max(result, prefix_g[i] - prefix_g[j-1]);
}
}
}
cout<<result<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 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 |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 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 |
380 KB |
Output is correct |
11 |
Correct |
2 ms |
376 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 |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
380 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
504 KB |
Output is correct |
7 |
Correct |
4 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
504 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
22 ms |
688 KB |
Output is correct |
12 |
Correct |
24 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
632 KB |
Output is correct |
2 |
Correct |
82 ms |
888 KB |
Output is correct |
3 |
Correct |
86 ms |
964 KB |
Output is correct |
4 |
Execution timed out |
1060 ms |
3320 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |