#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back
using namespace std;
ll i,n,ans,a[111111],b,c[111111];
bool can(ll k, ll kk){
ll md=(k+kk)/2,cst;
cst=(2*md-k-kk)*a[md]-c[md]+c[k]+c[kk+1]-c[md+1];
if(cst<=b) return 1;
else return 0;
}
ll fnd(ll k){
ll x=k,y=n;
while(x+1!=y){
ll mid=(x+y)/2;
if(can(k,mid))x=mid;
else y=mid;
}
return x;
}
int besthub(int R, int L, int X[], long long B) {
n=R;
b=B;
for(i=0;i<n;i++) a[i]=X[i];
c[0]=a[0];
for(i=1;i<n;i++)c[i]=c[i-1]+a[i];
for(i=0;i<R;i++) ans=max(ans,fnd(i)-i);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
3 ms |
488 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
488 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Incorrect |
3 ms |
652 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
652 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Incorrect |
3 ms |
652 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1108 KB |
Output is correct |
2 |
Correct |
7 ms |
1108 KB |
Output is correct |
3 |
Incorrect |
31 ms |
2540 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |