Zombies Arrive Before My Discharge
Time limit2sMemory limit1024 MB
Given zombies on a road with health values and three limited firearms, decide whether Kilo can kill or stop every zombie before the one 1 m from the post reaches it.
- Level
Medium5 of 10
- Topics
- Brute force, Simulation
- Solved
- No attempts yet
Problem
Sergeant Kilo and Private Hecto are on guard duty at the ammunition depot post. While keeping watch, Kilo spots a horde of zombies approaching and hurriedly calls the command center, but no one answers.
The road from the depot post is m long. A zombie m from the post has health . A zombie whose health drops to 0 or below dies permanently.
Kilo will hold off the zombies with personal firearms. He orders Hecto to carry ammunition.

Kilo's aimed shot always hits the front-most zombie on the road, no matter how far away it is.

Kilo cannot aim past the front-most zombie to hit one behind it. The aimed shot above is not possible.
While a zombie moves 1 m, Kilo can fire only one type of personal firearm, once.
Hecto is busy carrying ammunition and cannot fire.
The available firearms are as follows.
- Assault rifle (B1)


Reduces the health of the front-most zombie by . Remaining lethality does not carry over to the zombie behind. For example, a round that hits at 3 m with 6 lethality left does not carry over to a zombie at 4 m. Rifle rounds are unlimited.
- Shotgun (B2)


Reduces the health of the front-most zombie by . Remaining lethality does not carry over to the zombie behind. For example, a pellet that hits at 3 m with 6 lethality left does not carry over to a zombie at 4 m. There are shotgun shells.
- Sniper rifle (B3)


Reduces the health of zombies gathered within m of the first point of impact by for each 1 m. The lethality of a large-caliber round is effective only within m of the first point of impact. Remaining lethality and remaining penetration distance do not carry over to zombies behind. For example, if there is no zombie at 6 m, 1 m of penetration distance remains, but it does not carry over to a zombie at 8 m. There are large-caliber rounds.
Kilo and Hecto die if the zombie 1 m from the depot post is not suppressed after the shots are fired.
Can Kilo and Hecto survive?
Input
The first line contains the length of the road ().
The second line contains the lethality of a rifle round ().
The third line contains the lethality of a shotgun pellet () and the number of shotgun shells (), separated by a space.
The fourth line contains the lethality of a large-caliber round (), its effective penetration distance (), and the number of large-caliber rounds (), separated by spaces.
Each of the next lines contains one integer. The integer on line () is the health of the zombie m from the depot post (). means there is no zombie m from the post.
Output
Print YES if Kilo and Hecto can survive, and NO otherwise.