This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |