#include "bits/stdc++.h"
#include "ricehub.h"
using namespace std;
#define ll long long
int a[100010];
ll qs[100010];
bool price(int st , int ed , ll budget)
{
int mid = (st+ed)>>1;
ll temp = a[mid]*((mid-st)-(ed-mid)) - qs[mid-1] + qs[st-1] + qs[ed] - qs[mid];
if(temp<=budget) return 1;
else return 0;
}
int besthub(int n , int L , int X[] , ll budget)
{
for(int i=1;i<=n;i++)
{
a[i]=X[i-1];
qs[i]=qs[i-1]+a[i];
}
int mx=-1;
for(int i=1;i<=n;i++)
{
int st=i;
int ed=n;
while(st<=ed)
{
int mid = (st+ed)>>1;
if(price(i,mid,budget)) st=mid+1;
else ed=mid-1;
}
mx=max(mx,ed-i);
}
return mx;
}
// int main()
// {
// int r , lim ,x[100010];
// ll bud;
// cin >> r >> lim;
// for(int i=0;i<r;i++)
// {
// cin >>x[i];
// }
// cin >> bud;
// cout << besthub(r,lim,x,bud);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |