Submit | All submissions | Best solutions | Back to list |
VPL1_BC - Late Summer Battle |
"Finally people can rest. Last Autumn truce was signed. One year. Maybe coming Winter discouraged two nations to continue the slaughter. Summer begins and people are recovering the good mind and encouragement from old days. We hope diplomats achieve peace. I returned to my hometown, far from the Capitol, after a long training in Alchemy. Finally i can see my mother again. One year truce doesn't exist, it's peace or war. Today is War. I must defend my hometown" - N.F.
An Alchemist must create a resistance force quickly in order to defend people from an imminent attack from an enemy Army.
He knows many "formulas" for that. He can animate a mechanical soldier, create Golems, Homunculus and many other creatures.
Tactical Information
- He counts with an storage depot with some resources he can use to create some of his creatures.
- He assume the town will be attacked by waves. As soon as he'll see the wave, he can estimate the power of it. Sadly he can't know in advance the number and nature of the waves.
- Due to the lack of time, he can only create his creatures instantly, which means that after a battle, the creatures will disappear.
- He assign a performance value to each creature type based on his experience. As they are individual entities without soul, there is no synergy, so the performance value of two mechanical soldiers is equal to two times the value of one.
- For each wave, he'll create creatures enough to sum up performance power greater than the power of the wave.
- As there is little time, the priority is to create the least creatures possible to achieve the power needed. So he'll begin creating the creatures the greater performance value, then the next ones in performance value, and so on.
After all the waves are over, he'll move quickly to the next town, leaving everything behind, and protect it similarly.
Input
First line has a number T, indicating the number of towns to defend.
Then, for each town:
The first line contain two numbers N, M, separated by a space. N is the number of different resources available in this town and M the different creatures available to summon in this town.
Then N lines, with N + 1 integers. The n'th line represents the n'th resource type containing M + 1 integers separated by a space where the m'th integer represents how much of resource n is needed to create the creature m. The M + 1 integer represents how much of the n'th resource are in the storage depot.
Then a line with M integers separated by a space where the integer m represent the performance value of the m'th creature.
Last for each town an integer sequence representing the strength of each incoming wave to this town.
Output
For each town i, write "Scenario #i:" followed by:
- "Resistence" if the Alchemist could defend the town with the resources and described strategy.
- "Summer, Bloody Summer!" if the Alchemist couldn't defend the town.
Constraints
1 <= T <= 10
1 <= N <= 10
1 <= M <= 10
Example
Input: 2 6 3 2 0 0 200 0 10 0 30 0 0 10 100 1 5 1 100 50 500 0 5000 0 0 5 50 1 15 2 30 30 40 20 0 5 3 2 0 0 100 0 10 0 100 0 0 100 1000 1 5 5 200 50 500 1000 10000 1 15 12 30 30 40 80 40 30 30 20 0 Output: Scenario #1: Resistence! Scenario #2: Summer, Bloody Summer!
Explanation
The First Town
The resource depot has the following materials:
200 kg of copper, 30 kg of marble, 100 kg of magic soil, 100 crystals, 5000 g of sulfur and 50 l of blood. In that town, the Alchemist is able to create:
- Mechanical soldiers. Each one needs 2 kg of copper, 1 crystal and 50 g of sulfur. One mechanical soldier has a perform value of 1.
- Stone Golems. Each one needs 10 kg of marble, 5 crystals and 500 g of sulfur. One Stone Golem has a perform value of 15.
- Homunculus. Each one needs 10 kg magic soil, 1 crytal and 5 l of blood. One Homunculus has a perform value of 2.
And there come the following waves: 30, 30, 40 and 20.
After the strategy is performed with the available resources, the town resisted the attack: Resistance!
The alchemist goes to the next town...
The Second Town
The resource depot has the following materials:
100 kg of copper, 100 kg of marble, 1000 kg of magic soil, 200 crystals, 10000 g of sulfur. In that town, the alchemist is able to create:
- Mechanical soldiers. Each one needs 2 kg of copper, 1 crystal and 50 g of sulfur. One mechanical soldier has a perform value of 1.
- Stone Golems. Each one needs 10 kg of marble, 5 crystals and 500 g of sulfur. One Stone Golem has a perform value of 15.
- Earth Golems. Each one needs 100 kg of magic soil, 5 crystals and 500 g of sulfur.
And there come the following waves: 30, 30, 40, 80, 40, 30, 20.
After the strategy is performed with the available resources, the town couldn't resist the attack: Summer, Bloody Summer!
There are no more towns and the Alchemist leaves to the Capitol.
Added by: | Venezuelan Programming League |
Date: | 2013-03-08 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |