### Problem Statement

You are working as an analyst in the credit department of a bank. The bank has just issued several loans, each to be repaid with interest. Unfortunately, some debtors are unreliable and will not pay any money back to the bank. Your task is to estimate the expected profit the bank will get from this set of loans.

You are given a String[] loans, each element of which represents a single loan and is formatted as "AMOUNT INTEREST CLASS" (quotes for clarity only). AMOUNT is the base amount of the loan, INTEREST is the amount of interest the debtor must pay, and CLASS is the name of the debtor's risk class. You are also given a String[] riskClasses, each element of which represents a single risk class and is formatted as "CLASS PROB" (quotes for clarity only). CLASS is the name of the risk class, and PROB is the percent probability of a debtor in that risk class turning out to be unreliable.

An unreliable debtor will pay no money back to the bank. A reliable debtor will pay back the entire amount of the loan plus all of the interest. The bank's profit is the total amount of money (including interest) the bank will get back from its debtors minus the total amount of money it loaned out. Return the expected profit for the described set of loans.

### Definition

 Class: BankLoans Method: expectedProfit Parameters: String[], String[] Returns: double Method signature: double expectedProfit(String[] loans, String[] riskClasses) (be sure your method is public)

### Notes

-For the purposes of this problem we assume that debtors make their decisions on returning the loans independently.
-The returned value must have an absolute or relative error less than 1e-9.

### Constraints

-loans will contain between 1 and 50 elements, inclusive.
-Each element of loans will contain between 8 and 28 characters, inclusive.
-Each element of loans will be formatted as "AMOUNT INTEREST CLASS" (quotes for clarity only), where AMOUNT is an integer between 100 and 100000, inclusive, without leading zeroes, INTEREST is an integer between 10 and 20000, inclusive, without leading zeroes, and CLASS is a non-empty sequence of lowercase letters ('a'-'z').
-riskClasses will contain between 1 and 50 elements, inclusive.
-Each element of riskClasses will contain between 3 and 19 characters, inclusive.
-Each element of riskClasses will be formatted as "CLASS PROB" (quotes for clarity only), where CLASS is a non-empty sequence of lowercase letters ('a'-'z'), and PROB is an integer between 0 and 100, inclusive, without extra leading zeroes.
-Each CLASS will contain between 1 and 15 characters, inclusive.
-All CLASSes in riskClasses will be distinct.
-Each CLASS in loans will be described in riskClasses.

### Examples

0)

 `{"1000 100 a", "500 80 b", "600 120 c"}` `{"a 0", "b 5", "c 10"}`
`Returns: 199.0`
 The profit from the first loan is 100, since the debitor is reliable with probability 1.0. For the second loan the bank receives a profit of 80 with probability 0.95 and loses the initial amount of 500 with probability 0.05, so the expected profit is 80*0.95-500*0.05=51. For the third loan the expected profit is 48.
1)

 `{"1000 150 beta", "1500 200 beta", "2000 250 beta"}` `{"alpha 0", "beta 10", "gamma 20"}`
`Returns: 90.0`
 It is possible to have no debtors of a certain risk class.
2)

 `{"1000 400 hopeless", "1000 400 bad", "1000 400 weak"}` `{"weak 50", "bad 75", "hopeless 100"}`
`Returns: -1950.0`
 The expected profit can be negative despite a high interest rate.
3)

 `{"500 55 ok", "1500 170 fine"}` `{"ok 10", "fine 10"}`
`Returns: 2.5`
4)

 ```{"8132 19387 s", "20219 1791 iarkhyvewuqo", "19219 4464 s", "6947 18098 s", "28985 7338 iarkhyvewuqo", "21878 7894 iarkhyvewuqo", "21495 8307 s"}``` `{"s 13","iarkhyvewuqo 16"}`
`Returns: 39395.83`

#### Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=9929

#### Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13728&pm=9929

Nickolas

#### Testers:

PabloGilberto , Olexiy , ivan_metelsky

#### Problem categories:

Math, String Parsing