#include "ricehub.h"
long long prefix[100010];
long long sum(int a,int b){
if(a==0) return prefix[b];
return prefix[b]-prefix[a-1];
}
bool canUse(int from,int to,long long B){
int middle = (to+from)/2;
if((to-from)%2){
return sum(middle+1,to) - sum(from,middle) <= B;
} else {
return sum(middle+1,to) - sum(from, middle-1) <= B;
}
}
bool checkWidth(int r,long long Batt,int w){
int i;
if(w<=1) return true;
for(i=0;i+w-1<r;i++) {
if(canUse(i,i+w-1,Batt)) return true;
}
return false;
}
int besthub(int R, int L, int X[], long long B)
{
int i;
prefix[0]=X[0];
for(i=1;i<R;i++){
prefix[i]=prefix[i-1]+ X [i];
}
int left = 1, right = R+1;
int mid;
while(left+1 != right){
mid = (left+right)>>1;
if(checkWidth(R,B,mid)){
left=mid;
} else {
right=mid;
}
}
return left;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5776 KB |
Output is correct |
2 |
Correct |
0 ms |
5776 KB |
Output is correct |
3 |
Correct |
0 ms |
5776 KB |
Output is correct |
4 |
Correct |
0 ms |
5776 KB |
Output is correct |
5 |
Correct |
0 ms |
5776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5776 KB |
Output is correct |
2 |
Correct |
0 ms |
5776 KB |
Output is correct |
3 |
Correct |
0 ms |
5776 KB |
Output is correct |
4 |
Correct |
0 ms |
5776 KB |
Output is correct |
5 |
Correct |
0 ms |
5776 KB |
Output is correct |
6 |
Correct |
0 ms |
5776 KB |
Output is correct |
7 |
Correct |
0 ms |
5776 KB |
Output is correct |
8 |
Correct |
0 ms |
5776 KB |
Output is correct |
9 |
Correct |
0 ms |
5776 KB |
Output is correct |
10 |
Correct |
0 ms |
5776 KB |
Output is correct |
11 |
Correct |
0 ms |
5776 KB |
Output is correct |
12 |
Correct |
0 ms |
5776 KB |
Output is correct |
13 |
Correct |
0 ms |
5776 KB |
Output is correct |
14 |
Correct |
0 ms |
5776 KB |
Output is correct |
15 |
Correct |
0 ms |
5776 KB |
Output is correct |
16 |
Correct |
0 ms |
5776 KB |
Output is correct |
17 |
Correct |
0 ms |
5776 KB |
Output is correct |
18 |
Correct |
0 ms |
5776 KB |
Output is correct |
19 |
Correct |
0 ms |
5776 KB |
Output is correct |
20 |
Correct |
0 ms |
5776 KB |
Output is correct |
21 |
Correct |
0 ms |
5776 KB |
Output is correct |
22 |
Correct |
0 ms |
5776 KB |
Output is correct |
23 |
Correct |
0 ms |
5776 KB |
Output is correct |
24 |
Correct |
0 ms |
5776 KB |
Output is correct |
25 |
Correct |
0 ms |
5776 KB |
Output is correct |
26 |
Correct |
0 ms |
5776 KB |
Output is correct |
27 |
Correct |
0 ms |
5776 KB |
Output is correct |
28 |
Correct |
0 ms |
5776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5776 KB |
Output is correct |
2 |
Correct |
0 ms |
5776 KB |
Output is correct |
3 |
Correct |
0 ms |
5776 KB |
Output is correct |
4 |
Correct |
0 ms |
5776 KB |
Output is correct |
5 |
Correct |
0 ms |
5776 KB |
Output is correct |
6 |
Correct |
0 ms |
5776 KB |
Output is correct |
7 |
Correct |
0 ms |
5776 KB |
Output is correct |
8 |
Correct |
0 ms |
5776 KB |
Output is correct |
9 |
Correct |
0 ms |
5776 KB |
Output is correct |
10 |
Correct |
0 ms |
5776 KB |
Output is correct |
11 |
Correct |
0 ms |
5776 KB |
Output is correct |
12 |
Correct |
0 ms |
5776 KB |
Output is correct |
13 |
Correct |
0 ms |
5776 KB |
Output is correct |
14 |
Correct |
0 ms |
5776 KB |
Output is correct |
15 |
Correct |
0 ms |
5776 KB |
Output is correct |
16 |
Correct |
0 ms |
5776 KB |
Output is correct |
17 |
Correct |
0 ms |
5776 KB |
Output is correct |
18 |
Correct |
0 ms |
5776 KB |
Output is correct |
19 |
Correct |
0 ms |
5776 KB |
Output is correct |
20 |
Correct |
0 ms |
5776 KB |
Output is correct |
21 |
Correct |
0 ms |
5776 KB |
Output is correct |
22 |
Correct |
0 ms |
5776 KB |
Output is correct |
23 |
Correct |
0 ms |
5776 KB |
Output is correct |
24 |
Correct |
0 ms |
5776 KB |
Output is correct |
25 |
Correct |
0 ms |
5776 KB |
Output is correct |
26 |
Correct |
0 ms |
5776 KB |
Output is correct |
27 |
Correct |
0 ms |
5776 KB |
Output is correct |
28 |
Correct |
0 ms |
5776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5776 KB |
Output is correct |
2 |
Correct |
4 ms |
5776 KB |
Output is correct |
3 |
Correct |
16 ms |
5776 KB |
Output is correct |
4 |
Correct |
16 ms |
5776 KB |
Output is correct |
5 |
Correct |
12 ms |
5776 KB |
Output is correct |
6 |
Correct |
8 ms |
5776 KB |
Output is correct |
7 |
Correct |
8 ms |
5776 KB |
Output is correct |
8 |
Correct |
8 ms |
5776 KB |
Output is correct |
9 |
Correct |
16 ms |
5776 KB |
Output is correct |
10 |
Correct |
0 ms |
5776 KB |
Output is correct |
11 |
Correct |
8 ms |
5776 KB |
Output is correct |
12 |
Correct |
12 ms |
5776 KB |
Output is correct |
13 |
Correct |
12 ms |
5776 KB |
Output is correct |
14 |
Correct |
12 ms |
5776 KB |
Output is correct |
15 |
Correct |
8 ms |
5776 KB |
Output is correct |
16 |
Correct |
16 ms |
5776 KB |
Output is correct |
17 |
Correct |
16 ms |
5776 KB |
Output is correct |
18 |
Correct |
16 ms |
5776 KB |
Output is correct |
19 |
Correct |
20 ms |
5776 KB |
Output is correct |
20 |
Correct |
16 ms |
5776 KB |
Output is correct |