#include "ricehub.h"
using namespace std;
typedef long long ll;
int besthub(int R, int L, int X[], long long B)
{
ll pre[R + 1];
pre[0] = 0;
for(int i = 0; i < R; i++){
pre[i + 1] = X[i] + pre[i];
}
int lo = 0; int hi = R;
while(lo < hi){
ll mid = (lo + hi + 1)/2;
bool can = 0;
for(int i = 0; i + mid - 1 < R; i++){
ll sum = 0;
ll nos = (i + i + mid - 1)/2;
sum += X[nos]*mid - (pre[nos] - pre[i]);
sum += (pre[i + i + mid - 1] - pre[nos]) - X[nos]*mid;
if(sum <= B){
can = 1;
break;
}
}
if(can){
lo = mid;
}
else{
hi = mid - 1;
}
}
return lo;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |