If You Are Homeless... Just Build a House#10824

If You Are Homeless... Just Build a House (Розбір)

For a given region with values b_1\le b_2\le \ldots \le b_{hw}, the answer is the sum of , where med = \lfloor \frac{hw}{2} \rfloor. It can also be stated as the following: let's keep the set of smallest numbers $S_1