#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
long long sum[100000];
int besthub(int R, int L, int X[], long long B)
{
for(int i=0;i<R;i++){
if(i==0) sum[i]=X[i];
else sum[i]=sum[i-1]+X[i];
}
int ans=0;
for(int i=0;i<R;i++){
int l=i,r=R-1;
while(l<r){
int m=(l+r+1)>>1;
int x=i-1+(m-i+1)/2;
int y=m+1-(m-i+1)/2;
if(B>=(sum[m]-sum[y]+X[y]-sum[x]+sum[i]-X[x])){
l=m;
}
else r=m-1;
}
ans=max(ans,l-i+1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
576 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |