By Emilio Wuerges, UFFS Brazil
During winter, especially in the mountains, the weather can get very cold. On these occasions, the peão needs to prepare and dress accordingly.
Among other parts, the Bombacha, the Boot, the Hat, and the Scarf are part of the peão's clothing. Each of these parts can vary in quality and weight.
Calculate the maximum garment quality value given a maximum weight. Consider that the peão can wear 4 types of armor parts, but only one part of each type: Bombacha, the Boot, the Hat and the Scarf.
The first line consists of 4 integers H, C, S, P and one rational W, the number of Bombachas, Boots, Hats and Scarves available; and the maximum load, respectively.
Then, the input contains 4 pairs of lines, containing the statistics of the types of parts in this order: Bombachas, Boots, Hats and Scarves:
The first line of each pair has the part type quality values: \(d[p], d[p]
, \cdots, d[p][p_n] \).
The second line of each pair represents the weight of the part directly above: \(w[p], w[p] , \cdots, w[p][p_n] \).
The output contains a single rational number, the maximum quality possible.
|Input Sample||Output Sample|
1 1 1 1 10.1 5.0 1.0 6.0 2.0 11.0 100.0 23.0 3.0