# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17665 | ZiyaZa | Divide and conquer (IZhO14_divide) | C++14 | 69 ms | 7580 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 <iostream>
#include <cstdio>
#define pairr pair<long long,int>
#define f first
#define s second
using namespace std;
long long sumg[100010],sume[100010],a;
int n,x[100010],g[100010],e[100010],il,ir;
pairr sl[100010],sr[100010];
long long solve(int l, int r)
{
if (l==r)
{
return g[l];
}
if (l==r-1)
{
if (e[l]+e[r]>=x[r]-x[l]) return g[l]+g[r];
return max(g[l],g[r]);
}
int mid=(l+r)/2;
long long ans=max(solve(l,mid),solve(mid+1,r));
il=0;
ir=0;
for (int i=mid;i>=l;i--)
{
a=(i==0 ? sume[mid] : sume[mid]-sume[i-1])-(x[mid]-x[i]);
while (il>0 && a>=sl[il-1].f)
{
il--;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |