#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
bool price(int X[], int l,int r, long long B){
int i;
long long p = 0;
int m = (r + l) / 2;
for(i = l; i <m ; i++){
p +=(long long)X[m] - X[l];
}
for(i = m + 1; i <=r ; i++){
p +=(long long)X[i] - X[m];
}
if(p <= B){
return 1;
} else {
return 0;
}
}
int besthub(int n, int L, int X[], long long B)
{
int l = 0, r = 0, m,dif = -1,i;
for(i = 0; i < n;i++){
l = i; r = n;
while(l + 1!= r){
m = (l+r) / 2;
if(price(X,i,m,B) == 1){
l = m;
} else {
r = m;
}
}
dif = max(dif , r - l + 1);
}
return dif;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
142 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |