# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1189578 | diyah999 | Divide and conquer (IZhO14_divide) | C++20 | 151 ms | 144448 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// File input/output
freopen("divide.in", "r", stdin);
freopen("divide.out", "w", stdout);
ll n;
cin >> n;
vector<ll> x(n), g(n), d(n);
for (ll i = 0; i < n; ++i)
cin >> x[i] >> g[i] >> d[i];
ll ans = 0, totalG = 0, totalD = 0;
ll l = 0;
for (ll r = 0; r < n; ++r) {
totalG += g[r];
totalD += d[r];
while (l <= r && totalD < x[r] - x[l]) {
totalG -= g[l];
totalD -= d[l];
++l;
}
if (totalD >= x[r] - x[l])
ans = max(ans, totalG);
}
cout << ans << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |