#include "ricehub.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long
#define inf 1000000000
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
using namespace std;
int n,T[10],mx,ans;
lo int A[li],pre[li],b;
bool chechk(lo int l,lo int r){
int mid=(l+r)/2;
lo int sum=1ll*A[mid]*(mid-l+1)-(pre[mid]-pre[l-1]);
sum+=(pre[r]-pre[mid-1])-1ll*A[mid]*(r-mid+1);
return sum<=b;
}
int besthub(int R,int L,int X[],lo int B){
n=R;
for(int i=1;i<=n;i++) A[i]=X[i-1];
mx=L;
b=B;
for(int i=1;i<=n;i++) pre[i]=pre[i-1]+A[i];
for(int i=1;i<=n;i++){
int l=i,r=n;
while(l<=r){
int mid=(l+r)/2;
if(chechk(i,mid)) l=mid+1;
else r=mid-1;
}
ans=max(ans,l-i);
}
return ans;
}
//~ int main(){
//~ T[0]=1,T[1]=2,T[3]=10,T[4]=12,T[5]=14;
//~ int ty=besthub(5,20,T,6);
//~ printf("%d\n",ty);
//~ return 0;
//}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
3 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
524 KB |
Output is correct |
5 |
Correct |
2 ms |
524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
540 KB |
Output is correct |
2 |
Correct |
2 ms |
712 KB |
Output is correct |
3 |
Correct |
2 ms |
712 KB |
Output is correct |
4 |
Correct |
2 ms |
712 KB |
Output is correct |
5 |
Correct |
2 ms |
744 KB |
Output is correct |
6 |
Correct |
2 ms |
744 KB |
Output is correct |
7 |
Correct |
2 ms |
744 KB |
Output is correct |
8 |
Correct |
11 ms |
744 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
2 ms |
748 KB |
Output is correct |
12 |
Correct |
2 ms |
748 KB |
Output is correct |
13 |
Correct |
2 ms |
748 KB |
Output is correct |
14 |
Correct |
2 ms |
748 KB |
Output is correct |
15 |
Correct |
2 ms |
748 KB |
Output is correct |
16 |
Correct |
2 ms |
748 KB |
Output is correct |
17 |
Correct |
2 ms |
748 KB |
Output is correct |
18 |
Correct |
2 ms |
748 KB |
Output is correct |
19 |
Correct |
2 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
768 KB |
Output is correct |
21 |
Correct |
2 ms |
768 KB |
Output is correct |
22 |
Correct |
2 ms |
768 KB |
Output is correct |
23 |
Correct |
2 ms |
768 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
768 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
2 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Correct |
2 ms |
768 KB |
Output is correct |
3 |
Correct |
2 ms |
768 KB |
Output is correct |
4 |
Correct |
2 ms |
768 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
2 ms |
768 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
3 ms |
768 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
3 ms |
768 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
768 KB |
Output is correct |
16 |
Correct |
2 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
768 KB |
Output is correct |
18 |
Correct |
2 ms |
768 KB |
Output is correct |
19 |
Correct |
2 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
768 KB |
Output is correct |
21 |
Correct |
3 ms |
768 KB |
Output is correct |
22 |
Correct |
3 ms |
768 KB |
Output is correct |
23 |
Correct |
3 ms |
768 KB |
Output is correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
768 KB |
Output is correct |
26 |
Correct |
3 ms |
768 KB |
Output is correct |
27 |
Correct |
3 ms |
768 KB |
Output is correct |
28 |
Correct |
5 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1020 KB |
Output is correct |
2 |
Correct |
6 ms |
1020 KB |
Output is correct |
3 |
Correct |
28 ms |
2556 KB |
Output is correct |
4 |
Correct |
29 ms |
3788 KB |
Output is correct |
5 |
Correct |
13 ms |
3788 KB |
Output is correct |
6 |
Correct |
13 ms |
3788 KB |
Output is correct |
7 |
Correct |
41 ms |
5148 KB |
Output is correct |
8 |
Correct |
26 ms |
5920 KB |
Output is correct |
9 |
Correct |
15 ms |
5920 KB |
Output is correct |
10 |
Correct |
14 ms |
5920 KB |
Output is correct |
11 |
Correct |
30 ms |
7540 KB |
Output is correct |
12 |
Correct |
29 ms |
8608 KB |
Output is correct |
13 |
Correct |
14 ms |
8608 KB |
Output is correct |
14 |
Correct |
14 ms |
8608 KB |
Output is correct |
15 |
Correct |
23 ms |
9812 KB |
Output is correct |
16 |
Correct |
22 ms |
10468 KB |
Output is correct |
17 |
Correct |
26 ms |
11768 KB |
Output is correct |
18 |
Correct |
26 ms |
12712 KB |
Output is correct |
19 |
Correct |
29 ms |
13784 KB |
Output is correct |
20 |
Correct |
28 ms |
14820 KB |
Output is correct |