Let $n,k$ be any positive integers. What is the lowest $r$ (possibly depending on $n,k$) such that given real numbers $0\leq a_1,\dots,a_n\leq 1$, it is always possible to partition them into $k$ blocks, where each block contains consecutive elements of the sequence, so that the sums of any two blocks differ by at most $r$?

Taking the example when $a_1=1$ and $a_2=\dots=a_n=0$, we need $r\geq 1$. On the other hand, $r\leq 2$ as we can use an algorithm where we process numbers from left to right and create a new block each time the total sum exceeds $\frac{i}{k}(a_1+\dots+a_n)$ for $1\leq i\leq n-1$.

I suspect this problem must have been studied before. Are there any references?