Facer was addicted to a popular game called “Plants VS Zombies”. After Facer had completed all missions, he started to play the zombies’ role to destroy plants and called the new game “Zombies VS Plants”.
In the game “Zombies VS Plants”, there are 3 kinds of zombies: Little Zombie, Adult Zombie and Football player. Different zombies have different price and different “attacking value” indicating the capability to attack, as shown in the table below:
Spiders also can destroy the plants. Every spider costs 125 dollars.
There are 4 kinds of plants: Sunflower, Bean, Magnet and Lettuce. Every plant has a “defending value” indicating it’s capability of defense.
Facer’s mission is to destroy ALL the plants in the field. In order to destroy plants, Facer needs to buy zombies or spiders and put them into the field. The plants field can be considered as a 5×5 grid(of course 25 cells), as shown in the figure below:
There is a plant in every cell. Facer can destroy plants only by two ways:
1. If Facer puts one or more zombies together into a row of the field, and the sum of those zombies’ attacking values is larger than the sum of defending values of the plants in the same row, all plants in that row will be destroyed.
2. Putting a spider in a cell will destroy the plant in it. But there are some exceptions as shown in the description of plant “Lettuce” in a table below.
Once a zombie is put into the plants field, it dies immediately after destroying the plants. So does a spider. In other words, Facer can use a zombie or a spider only once.
This is a table describing the features of different kinds of plants:
Facer can earn P1 dollars after destroying a row of plants, and destroying a sunflower will earn extra P2 dollars for him. Facer has P3 dollars but no zombies and no spiders at the begging. Of course Facer can use the money he earned to buy zombies and spiders.
Your job is helping Facer to accomplish his mission and keep money as much as possible after the mission.