#include "ricehub.h"
typedef long long ll;
int arre[100002];
ll presupuesto;
int campos;
bool probar(int campos_arroz){
ll aux = 0;
int centro = campos_arroz / 2;
for(int i = 0; i < campos_arroz; ++i){
ll aux2 = (ll) arre[centro] - (ll) arre[i];
if(aux2 < 0){
aux2 *= -1LL;
}
aux += aux2;
}
if(aux <= presupuesto){
return 1;
}
for(int i = campos_arroz; i < campos; ++i){
centro++;
aux -= (ll) arre[centro - 1] - (ll) arre[i - campos_arroz];
aux += (ll) arre[i] - (ll) arre[centro];
if(campos_arroz % 2 == 0){
aux -= ((ll) arre[centro] - (ll) arre[centro - 1]);
}
if(aux <= presupuesto){
return 1;
}
}
return 0;
}
int bs(int li, int ls){
int mitad, resbs = 0;
while(li <= ls){
mitad = (li + ls) / 2;
if(probar(mitad)){
resbs = mitad;
li = mitad + 1;
}
else{
ls = mitad - 1;
}
}
return resbs;
}
int besthub(int R, int L, int X[], long long B)
{
presupuesto = B;
for(int i = 0; i < R; ++i){
arre[i] = X[i];
}
campos = R;
return bs(1, R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |