Company: KPIT
Difficulty: medium
Arlen The Warrior In a mystical realm, a warrior named Arlen is tasked with defending the land from ferocious beast packs. There are n packs of beasts scattered across the kingdom, and the i -th pack contains b[i] beasts. To protect the realm, Arlen must eliminate every single beast in all the packs. Arlen has two types of attacks available and a special power gauge p , initially set to 0 . Basic Strike: Arlen chooses a pack i that still contains at least one beast and slays exactly one beast from that pack. After the strike, the gauge p increases by 1 . Ultimate Cleave: Arlen chooses a pack i that currently contains at least p beasts, and slays exactly p beasts from that pack in one blow. After this attack, the gauge p is reset to 0 . Each attack of either kind counts as one attack. Arlen may perform the attacks in any order he likes, and he may target a different pack with each attack. Arlen needs to clear all packs as swiftly as possible. Determine the minimum number of attacks requ