B - ARC Wrecker Editorial by evima

If there are \(Q_i\) “floors” such that there are \(i\) buildings with it, there can be between \(0\) and \(Q_i\) such floors in the final scenery, for every \(i\).

Thus, the answer is \(\prod_{i=1}^{N} \left(A'_i - A'_{i-1} + 1\right)\), where \(A' = (A'_1, A'_2, ..., A'_N)\) is the result of sorting \(A\) in ascending order and \(A'_0 = 0\).

Sample Implementation:

last update: