创建于 2026/07/18 · 更新于 2026/07/18
Monster Train 2 is an excellent roguelike deck-building game. During combat, friendly units attack enemy units every turn. Consider a friendly unit that has all three effects Quick, Trample, and Sweep: it attacks before enemy units, hits every enemy unit, and carries excess damage onward.
There are enemy units on the same floor, arranged from front to back and numbered in that order. The -th enemy unit has Health, where is a positive integer.
For this problem, the unit's Attack is a non-negative integer . At the beginning of its turn, the combined effect of Quick, Trample, and Sweep is modeled as follows:
If no enemy unit survives the first step, all of them are immediately considered defeated.
For every , suppose that only the first enemy units are present. Find the minimum Attack required for the friendly unit to defeat all of them in this turn.
The first line contains one integer (), the number of enemy units.
The second line contains integers (), the initial Health values of the enemy units in front-to-back order.
Output integers. The -th integer must be the answer when only the first enemy units are present.
5
1 4 2 5 3
1 3 3 4 4