E - Expected Rain
CodeChefOpen on judge ↗
There are $N$ buildings on a $1$-D line. The $i$-th building spans from $x$-coordinate $(i - 1)$ to $x$-coordinate $i$, and has a height of $H_i$. When rain falls, water gets collected between the buildings. There are no buildings to the left of $x = 0$ or to the right of $x = N$, and so no water gets collected there. Let $f(H)$ denote the amount of rain collected. ------- Unfortunately, yo
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start