#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int n, l, x[N], g[N], e[N];
ll de[N], dg[N], ans;
int main() {
// freopen("divide.in", "r", stdin);
// freopen("divide.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> x[i] >> g[i] >> e[i];
dg[i] += dg[i - 1] + g[i];
de[i] += de[i - 1] + e[i];
if (x[i] - x[l + 1] <= de[i] - de[l] && dg[i] - dg[l] > ans) {
ans = dg[i] - dg[l];
}
if (g[i] > ans) {
ans = g[i];
}
if (dg[i] < dg[l]) {
l = i;
}
}
// for (int l = 1; l <= n; ++l) {
// for (int r = l; r <= n; ++r) {
// int len = x[r] - x[l];
//// cout << l << " " << r << " " << dg[r] - dg[l - 1] << "\n";
// if (len <= de[r] - de[l - 1] && dg[r] - dg[l - 1] > ans) {
// ans = dg[r] - dg[l - 1];
// }
// }
// }
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4748 KB |
Output is correct |
2 |
Incorrect |
0 ms |
4748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4748 KB |
Output is correct |
2 |
Correct |
0 ms |
4748 KB |
Output is correct |
3 |
Incorrect |
0 ms |
4748 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4748 KB |
Output is correct |
2 |
Correct |
6 ms |
4748 KB |
Output is correct |
3 |
Correct |
9 ms |
4748 KB |
Output is correct |
4 |
Correct |
83 ms |
4748 KB |
Output is correct |
5 |
Correct |
63 ms |
4748 KB |
Output is correct |
6 |
Correct |
169 ms |
4748 KB |
Output is correct |
7 |
Correct |
106 ms |
4748 KB |
Output is correct |
8 |
Correct |
113 ms |
4748 KB |
Output is correct |
9 |
Correct |
109 ms |
4748 KB |
Output is correct |
10 |
Incorrect |
109 ms |
4748 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |