# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638943 | bonk | Divide and conquer (IZhO14_divide) | C++14 | 1 ms | 316 KiB |
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;
using ll = long long;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
vector<tuple<ll, ll, ll>>v(n);
for(int i = 0; i < n; i++){
ll x, g, d; cin >> x >> g >> d;
v[i] = {x, g, d};
}
ll ans = 0;
for(int i = 0; i < n; i++){
auto [x1, g1, d1] = v[i];
ans = max(ans, g1);
ll tmp = g1;
ll energy = d1;
for(int j = i + 1; j < n; j++){
auto [x2, g2, d2] = v[j];
ll dis = x2 - x1;
energy += d2;
tmp += g1;
if(energy >= dis) ans = max(ans, tmp);
}
}
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... |