All problems

The Expected Payout

mediumPythonStatisticsProbability

Marchmont Games is pricing a new arcade cabinet. Every play ends in one of a fixed set of outcomes, and each outcome pays a known amount with a known probability. Before the cabinet ships, finance needs the expected value of a single play — the amount the machine pays out per play averaged over a very long run of plays. A negative payout is money the player hands over to the machine.

Task: Print the expected value of one play.

Input

The first line holds one integer n, how many outcomes follow. Each of the next n lines holds two plain numbers separated by a single space: that outcome's payout, then its probability. A payout may be negative. The outcomes listed cover every possibility, so their probabilities add up to 1.

Output

One line holding the expected value with exactly two digits after the decimal point.

Example:

Input:
3
100 0.1
10 0.3
0 0.6

Output:
13.00

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…