| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 570562 | Hanksburger | Divide and conquer (IZhO14_divide) | C++17 | 45 ms | 8148 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;
#define ll long long
ll a[100005], b[100005], c[100005], d[100005], e[100005];
vector<pair<ll, ll> > vec;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n, ans=0;
cin >> n;
for (ll i=1; i<=n; i++)
{
ll x, y, num;
cin >> a[i] >> x >> y;
b[i]=b[i-1]+x;
c[i]=c[i-1]+y;
num=c[i]-a[i];
while (vec.size() && vec[vec.size()-1].first<=num)
vec.pop_back();
vec.push_back({num, i});
}
reverse(vec.begin(), vec.end());
for (int i=0; i<vec.size(); i++)
{
d[i]=vec[i].first;
e[i]=vec[i].second;
}
for (ll i=1; i<=n; i++)
{
int ind=lower_bound(d, d+vec.size(), c[i-1]-a[i])-d;
ans=max(ans, b[e[ind]]-b[i-1]);
}
cout << ans;
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... | ||||
