Online allocation and homogeneous partitioning for piecewise constant mean-approximation