This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Take me to church
I'll worship like a dog at the shrine of your lies
I'll tell you my sins and you can sharpen your knife
Offer me that deathless death
Good God, let me give you my life
*/
#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
const int N = 100005;
int n, L, A[N];
ll B, P[N];
inline bool SolveOdd(int md)
{
md >>= 1;
for (int i = md + 1; i + md <= n; i ++)
if (P[i + md] + P[i - 1 - md] - P[i] - P[i - 1] <= B)
return (1);
return (0);
}
inline bool SolveEven(int md)
{
md >>= 1; md --;
for (int i = md + 1; i + md + 1 <= n; i ++)
if (P[i + md + 1] + P[i - 1 - md] - P[i] - P[i - 1] <= B + A[i])
return (1);
return (0);
}
inline bool Solve(int md)
{
if (md & 1)
return (SolveOdd(md));
return (SolveEven(md));
}
int besthub(int _n, int _L, int * _A, ll _B)
{
n = _n; L = _L; B = _B;
for (int i = 1; i <= n; i ++)
A[i] = _A[i - 1], P[i] = P[i - 1] + A[i];
int le = 1, ri = n + 1, md;
while (ri - le > 1)
{
md = (le + ri) >> 1;
if (Solve(md))
le = md;
else
ri = md;
}
return (le);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |