i has armor[i] points of armor. A catapult fires one shot at a time. For every shot you pick one wall: it loses direct points of armor, while **every other** wall loses splash points from flying debris.
A wall is down once its armor is zero or negative (shooting at a wall that is already down is allowed).
Return the smallest number of shots after which every wall is down.armor=[5, 9, 2], direct=5, splash=2 → 3
Two shots at wall 1 leave the armor at [1, -1, -2]. A third shot at wall 0 gives [-4, -3, -4], and every wall is down. Two shots are not enough: wall 1 would need both, leaving wall 0 with only 4 damage.
armor=[3, 3], direct=3, splash=1 → 2
The first shot hits wall 0: [0, 2]. The second hits wall 1: [-1, -1].
armor=[4], direct=7, splash=1 → 1
A single wall, and one direct shot removes 7 points of armor.
armor.length ≤ 10⁵armor[i] ≤ 10⁹splash < direct ≤ 10⁹armor=[5, 9, 2], direct=5, splash=2
3
Run checks the first 3 tests in your browser. Submit checks all 106 tests on the server, hidden ones included.