#include "ricehub.h"
#include <cstdlib>
#include <iostream>
#define dist(a,b)abs(X[a]-X[b])
bool ishub(int R, int X[], long long B, int A) {
if (A==1) return true;
int M = A/2,I=-1,C=0;
while (++I<A)C+=dist(I,M);
--I;while (C>B&&++I<R) {
C-=dist(I-A, M);
C-=dist(M, M+1);
C+=dist(I, ++M);
}
return C<=B;
}
int besthub(int R, int L, int X[], long long B) {
int A=1;
while (ishub(R, X, B, A)) ++A;
return --A;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |