#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,v,a[100005],sum[100005],ans=-1;
bool check(ll l,ll r)
{
ll mid=(l+r)/2;
return ((sum[r]-sum[mid])-(sum[mid-1]-sum[l-1])-a[mid]*((r-l)&1))<=v;
}
int besthub(int n,int L,int A[], long long B)
{
v=B;
for(int i=1;i<=n;i++) a[i]=A[i-1];
for(ll i=1;i<=n;i++)
{
sum[i]=sum[i-1]+a[i];
}
for(ll l=1,r=0;l<=n;l++)
{
while(r<n&&check(l,r+1))
r++;
ans=max(ans,r-l+1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
312 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
304 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
308 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
312 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
444 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
444 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
596 KB |
Output is correct |
2 |
Correct |
3 ms |
832 KB |
Output is correct |
3 |
Correct |
12 ms |
3208 KB |
Output is correct |
4 |
Correct |
12 ms |
3276 KB |
Output is correct |
5 |
Correct |
5 ms |
1600 KB |
Output is correct |
6 |
Correct |
6 ms |
1748 KB |
Output is correct |
7 |
Correct |
10 ms |
3028 KB |
Output is correct |
8 |
Correct |
14 ms |
3036 KB |
Output is correct |
9 |
Correct |
5 ms |
1568 KB |
Output is correct |
10 |
Correct |
5 ms |
1492 KB |
Output is correct |
11 |
Correct |
14 ms |
3248 KB |
Output is correct |
12 |
Correct |
13 ms |
3252 KB |
Output is correct |
13 |
Correct |
5 ms |
1620 KB |
Output is correct |
14 |
Correct |
5 ms |
1600 KB |
Output is correct |
15 |
Correct |
9 ms |
2508 KB |
Output is correct |
16 |
Correct |
9 ms |
2516 KB |
Output is correct |
17 |
Correct |
11 ms |
2900 KB |
Output is correct |
18 |
Correct |
10 ms |
2976 KB |
Output is correct |
19 |
Correct |
11 ms |
3116 KB |
Output is correct |
20 |
Correct |
13 ms |
3084 KB |
Output is correct |