#K53987. Artifact Power Maximization
Artifact Power Maximization
Artifact Power Maximization
You are given several test cases. In each test case, you have a list of available items and a list of artifacts. Each artifact requires a set of items and has an associated power level.
An artifact can only be activated if all of its required items are available. Your task is to determine the highest possible power level among the activated artifacts for each test case. Output the result as a floating-point number rounded to three decimal places. If no artifact can be activated, output 0.000.
The required items for each artifact are provided along with its power level. Use efficient methods to check item availability and determine the maximum power level.
inputFormat
The input is read from standard input (stdin) and follows the format below:
t n id_1 effect_1 id_2 effect_2 ... id_n effect_n m k_1 item_1 item_2 ... item_k1 power_1 k_2 item_1 item_2 ... item_k2 power_2 ...
Where:
t
is the number of test cases.- For each test case,
n
is the number of available items. - Each of the next
n
lines contains two integers: the item id and its effect (the effect value is not used in the computation). - After that, an integer
m
denotes the number of artifacts. - For each artifact, the line begins with an integer
k
representing the number of required items, followed byk
integers (the required item ids), and a floating-point number representing the artifact's power level.
outputFormat
For each test case, output a single line containing the highest power level (formatted to three decimal places) of an artifact that can be activated. If no artifact can be activated, output 0.000.
## sample3
3
1 100
2 200
3 300
3
2 1 2 1500.45
2 2 3 2000.50
2 1 3 1800.30
3
3
1 100
2 200
3 300
0
2
1 50
2 100
2
2 1 2 1000.25
1 2 500.75
2000.500
0.000
1000.250
</p>