#P4042. [AHOI2014/JSOI2014] 骑士游戏
[AHOI2014/JSOI2014] 骑士游戏
Description
In this game, JYY has two attack types: a normal attack and a spell attack. Both consume some of JYY’s stamina. Using a normal attack on a monster does not completely kill it; the monster’s corpse can transform into some new monsters. Note that after several normal attacks, a monster may turn into one or more monsters of the same type again. A spell attack, however, can permanently kill a monster. Of course, in general, compared with a normal attack, a spell attack consumes more stamina (but due to a game system bug, this is not guaranteed).
There are different kinds of monsters in the game world, numbered from to . Now a monster of type has invaded the village. JYY wants to know the minimum stamina needed to kill all monsters in the village.
Input Format
The first line contains an integer .
Then lines follow, each describing one monster type.
The -th line contains several integers. The first three integers are , , and , meaning: for monster type , a normal attack costs stamina, a spell attack costs stamina, and after monster dies (by a normal attack), it spawns new monsters. After these three integers, there are exactly more integers, each giving the type number of one newly spawned monster. The same type number may appear multiple times.
Output Format
Output one integer on a single line: the minimum stamina required.
4
4 27 3 2 3 2
3 5 1 2
1 13 2 4 2
5 6 1 2
26
Hint
First use a normal attack costing stamina, and the spawned monster types are , , and . Spend stamina using spell attacks to kill the two monsters of type . For the remaining type monster, use a normal attack costing stamina. Now the monsters in the village are of types and . Finally, spend stamina using spell attacks to permanently kill these two monsters. The total stamina spent is .
Constraints: For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号