All problems

A Weighted Ensemble

mediumPythonEnsembles & Regularization

Ardwick Mutual has been tracking how each model on the panel actually performs, and no longer wants them treated as equals. Alongside the estimates, the desk now supplies one weight per model, scored from that model's record. The weights arrive exactly as the scoring run produced them — raw scores, in no particular scale, not tidied into anything that adds up neatly. The panel still has to produce one figure for the file.

Task: Print the single cost figure the weighted panel settles on.

Input

Three lines. The first holds one integer m, the number of models. The second holds m cost estimates separated by single spaces. The third holds m weights, in the same model order, separated by single spaces.

Output

One line holding the panel's figure rounded to 2 decimal places. Each model's estimate pulls on the answer in proportion to its own weight measured against the total weight on the panel, so the weights are read as relative sizes and need not already add up to 1.

Example:

Input:
2
10 20
1 3

Output:
17.50

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…