Histogram Reordering

Limits 1s, 512 MB

You are given an array of integers HHH, representing the height of the bars of a histogram. The width of each bar is `1`

. Now you will reorder the bars in such a way that the largest area of a rectangle in your histogram is the maximum possible amongst all possible reorderings.

This is a companion discussion topic for the original entry at https://toph.co/p/histogram-permutation