#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,b,ans;
lo int A[li],pre[li];
bool chechk(int l,int r){
int mid=(l+r)/2;
lo int sum=A[mid]*(mid-l+1)-(pre[mid]-pre[l-1]);
sum+=(pre[r]-pre[mid-1])-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 |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
624 KB |
Output is correct |
3 |
Correct |
2 ms |
624 KB |
Output is correct |
4 |
Correct |
2 ms |
700 KB |
Output is correct |
5 |
Correct |
2 ms |
744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1008 KB |
Output is correct |
2 |
Correct |
3 ms |
1008 KB |
Output is correct |
3 |
Correct |
2 ms |
1008 KB |
Output is correct |
4 |
Correct |
3 ms |
1008 KB |
Output is correct |
5 |
Correct |
3 ms |
1008 KB |
Output is correct |
6 |
Correct |
2 ms |
1012 KB |
Output is correct |
7 |
Correct |
2 ms |
1016 KB |
Output is correct |
8 |
Correct |
2 ms |
1020 KB |
Output is correct |
9 |
Correct |
2 ms |
1024 KB |
Output is correct |
10 |
Correct |
2 ms |
1028 KB |
Output is correct |
11 |
Correct |
2 ms |
1032 KB |
Output is correct |
12 |
Correct |
2 ms |
1032 KB |
Output is correct |
13 |
Correct |
2 ms |
1040 KB |
Output is correct |
14 |
Correct |
2 ms |
1044 KB |
Output is correct |
15 |
Correct |
2 ms |
1048 KB |
Output is correct |
16 |
Correct |
2 ms |
1072 KB |
Output is correct |
17 |
Correct |
2 ms |
1076 KB |
Output is correct |
18 |
Correct |
2 ms |
1080 KB |
Output is correct |
19 |
Correct |
2 ms |
1084 KB |
Output is correct |
20 |
Correct |
2 ms |
1088 KB |
Output is correct |
21 |
Correct |
2 ms |
1092 KB |
Output is correct |
22 |
Correct |
2 ms |
1096 KB |
Output is correct |
23 |
Correct |
2 ms |
1100 KB |
Output is correct |
24 |
Correct |
2 ms |
1100 KB |
Output is correct |
25 |
Correct |
3 ms |
1108 KB |
Output is correct |
26 |
Correct |
2 ms |
1112 KB |
Output is correct |
27 |
Correct |
2 ms |
1116 KB |
Output is correct |
28 |
Correct |
2 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1228 KB |
Output is correct |
2 |
Correct |
2 ms |
1228 KB |
Output is correct |
3 |
Correct |
2 ms |
1228 KB |
Output is correct |
4 |
Correct |
2 ms |
1228 KB |
Output is correct |
5 |
Correct |
2 ms |
1228 KB |
Output is correct |
6 |
Correct |
2 ms |
1272 KB |
Output is correct |
7 |
Correct |
2 ms |
1272 KB |
Output is correct |
8 |
Correct |
2 ms |
1272 KB |
Output is correct |
9 |
Correct |
2 ms |
1272 KB |
Output is correct |
10 |
Correct |
2 ms |
1272 KB |
Output is correct |
11 |
Correct |
2 ms |
1272 KB |
Output is correct |
12 |
Correct |
2 ms |
1272 KB |
Output is correct |
13 |
Correct |
3 ms |
1272 KB |
Output is correct |
14 |
Correct |
2 ms |
1272 KB |
Output is correct |
15 |
Correct |
2 ms |
1280 KB |
Output is correct |
16 |
Correct |
2 ms |
1280 KB |
Output is correct |
17 |
Correct |
3 ms |
1280 KB |
Output is correct |
18 |
Correct |
2 ms |
1296 KB |
Output is correct |
19 |
Correct |
2 ms |
1304 KB |
Output is correct |
20 |
Correct |
2 ms |
1312 KB |
Output is correct |
21 |
Correct |
3 ms |
1448 KB |
Output is correct |
22 |
Correct |
4 ms |
1448 KB |
Output is correct |
23 |
Correct |
3 ms |
1496 KB |
Output is correct |
24 |
Correct |
4 ms |
1528 KB |
Output is correct |
25 |
Correct |
4 ms |
1564 KB |
Output is correct |
26 |
Correct |
3 ms |
1712 KB |
Output is correct |
27 |
Correct |
3 ms |
1712 KB |
Output is correct |
28 |
Correct |
3 ms |
1712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2104 KB |
Output is correct |
2 |
Correct |
7 ms |
2240 KB |
Output is correct |
3 |
Incorrect |
28 ms |
4876 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |