Submission #17665

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
176652016-01-08 17:00:18ZiyaZaDivide and conquer (IZhO14_divide)C++14
100 / 100
69 ms7580 KiB
#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--;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...