低軌道Prefix maxima12月3日 00:00 公開

3日目:Snow Drift

The habitat ring's roofline is a single row of panels of different heights, and a storm of artificial snow has just been switched on for the season. Your input is one line of comma-separated panel heights, left to right. Each panel is one unit wide.

Snow settles flat and fills every dip it can: above each panel, snow rises to the lower of the tallest panel to its left (including itself) and the tallest panel to its right (including itself). Anything above that spills away. For example:

4,1,3,0,2,5,1,2

The snow levels are 4,4,4,4,4,5,2,2, so the panels hold 0+3+1+4+2+0+1+0 = 11 units of snow.

How much snow is trapped on your roofline?

例題の解き方を見る

ステップ 10/10
41302512
snow
11
11 units of snow are trapped.