/*
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
288 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
896 KB |
Output is correct |
2 |
Correct |
4 ms |
768 KB |
Output is correct |
3 |
Correct |
18 ms |
2944 KB |
Output is correct |
4 |
Correct |
18 ms |
2944 KB |
Output is correct |
5 |
Correct |
8 ms |
1408 KB |
Output is correct |
6 |
Correct |
8 ms |
1408 KB |
Output is correct |
7 |
Correct |
16 ms |
2688 KB |
Output is correct |
8 |
Correct |
16 ms |
2688 KB |
Output is correct |
9 |
Correct |
8 ms |
1408 KB |
Output is correct |
10 |
Correct |
8 ms |
1408 KB |
Output is correct |
11 |
Correct |
19 ms |
2944 KB |
Output is correct |
12 |
Correct |
19 ms |
2944 KB |
Output is correct |
13 |
Correct |
9 ms |
1536 KB |
Output is correct |
14 |
Correct |
9 ms |
1536 KB |
Output is correct |
15 |
Correct |
15 ms |
2304 KB |
Output is correct |
16 |
Correct |
15 ms |
2304 KB |
Output is correct |
17 |
Correct |
18 ms |
2816 KB |
Output is correct |
18 |
Correct |
18 ms |
2680 KB |
Output is correct |
19 |
Correct |
18 ms |
2816 KB |
Output is correct |
20 |
Correct |
19 ms |
2816 KB |
Output is correct |