#K67237. Minimum Rounds to Defeat Monsters
Minimum Rounds to Defeat Monsters
Minimum Rounds to Defeat Monsters
You are given a hero with a normal attack power \(A\) and a special attack that deals \(2A\) damage. The hero is faced with \(n\) monsters whose health points are given in an array. In one round, the hero can attack one monster. If the monster's health is less than or equal to \(A\), it can be defeated with a normal attack. If its health is more than \(A\) but less than or equal to \(2A\) and if the hero has at least one special attack remaining, the hero can defeat it using a special attack (using up one special attack). Otherwise, the hero still defeats the monster in one round using a normal attack. Your task is to determine the minimum number of rounds required to defeat all monsters.
Note: The monsters are attacked in the order of increasing health.
inputFormat
The input is read from stdin and has the following format:
A S n h1 h2 h3 ... hn
where:
A
is the integer representing the hero's normal attack power.S
is the number of special attacks available.n
is the number of monsters.h1, h2, ..., hn
are the integers representing the health points of each monster.
outputFormat
Output a single integer to stdout representing the minimum number of rounds required for the hero to defeat all the monsters.
## sample5 1
4
6 3 8 10
4