Codeforces Round #616 Coffee Varieties

题意

不太容易讲清,看英文吧
codeforces

做法

先从简单的看起
将块以\(\frac{k}{2}\)个元素为界,然后类似线段树一样递归下去,每次一层的左子树跟右子树的块相互暴力比较

\[\begin{cases}T(n)=n&n\le k\\T(n)=2T(\frac{n}{2})+\frac{n^2}{k}&other \end{cases} \]

再看困难的
块以\(k\)为界,然后以每个块作为起点:\(s\longrightarrow s-1\longrightarrow s+1...\),这样能做到\(\frac{n^2}{k}\)

原文地址:https://www.cnblogs.com/Grice/p/12270205.html