#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)
{
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 |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |