## Day 1, Problem 2 - Cash Exchange

Little Y has recently been working at a currency exchange center. The currency exchange center only offers two types of vouchers to be exchanged: commemorative voucher A (henceforth known as voucher A) and commemorative voucher B (henceforth known as voucher B). All voucher-holding customers possess their very own account. The quantity of vouchers a customer has may be a real number.

Rising and falling daily with the waves of the market, the two types of vouchers each has their own values at any given time, and each unit of a voucher can be traded that day for some amount of cash. We note that on day K, the values of voucher A and voucher B are respectively AK and BK (dollars/unit voucher).

To make it more convenient for customers, the exchange center offers a very easy system to make transactions: the ratio exchange method. There are two different aspects to the ratio exchange method:

1. Selling vouchers: the customer provides a real number OP in the range [0, 100] as the selling ratio. This means that OP% of voucher A and OP% of voucher B are exchanged for cash with the rate at that point in time.
2. Buying vouchers: the customer pays IP dollars, and the exchange center takes this money to exchange it for vouchers. Furthermore, the ratio between the value of voucher A and voucher B on day K just happens to be RateK.

For example, let's assume for the next 3 three days the following changes in the values of AK, BK, and RateK:

TimeAKBKRateK
Day 1111
Day 2122
Day 3223

Let's say that on one day, a customer has 100 dollars but no vouchers of any kind. The customer carry out the following transactions:

TimeTransactionCash (Dollars)Voucher AVoucher B
InitialNone10000
Day 2Sell – 50%752525
Day 3Sell – 100%20500

Note that there may be multiple transactions on a single day.

Little Y is a very economically-minded worker. After a relatively long time conducting operations and market estimates, he already knows within the future N days what the values of vouchers A and B, as well as rate will be. He wishes to calculate, if one starts with S dollars, what is the maximum amount of cash (in dollars) that can be obtained after N days.

### Input Format

The first line contains two positive integers N and S, representing the number of days that little Y's can foresee and the starting amount of cash respectively.
Within the next N lines, the K-th line contains three real numbers AK, BK, and RateK.

### Output Format

Output a single real number MaxProfit, indicating the maximum amount of cash in dollars that can be obtained after all operations on the N-th day has finished, accurate to 3 decimal places. Your answer will be considered correct if its absolute difference with the correct answer is no larger than 0.001.

```3 100
1 1 1
1 2 2
2 2 3
```

### Sample Output

```225.000
```

### Explanation

TimeTransactionCash (Dollars)Voucher AVoucher B
InitialNone10000
Day 2Sell – 100%15000
Day 3Sell – 100%22500

### Constraints

The test data ensures that the precision needed for calculations will not exceed 10−7.
For 40% of the test cases, N ≤ 10;
For 60% of the test cases, N ≤ 1 000;
For 100% of the test cases, N ≤ 100 000;
For 100% of the test cases:

• 0 < AK ≤ 10;
• 0 < BK ≤ 10;
• 0 < RateK ≤ 100;
• MaxProfit ≤ 109.

### Hints

The input may be very large, please use faster methods of input.
There must be an optimal series of transaction satisfying the conditions:

• each buying transaction uses up all of the cash, and
• each selling transaction sells all of the vouchers.

Point Value: 30 (partial)
Time Limit: 1.00s
Memory Limit: 256M

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

• (1/0)
"Furthermore, the ratio between the value of voucher A and voucher B on day K just happens to be RateK."
It's much better to say "Amount of" instead of "Value of".

Another Edit: About a year ago.

• (0/0)
* We note that on day K, the values of voucher A and voucher B are respectively AK and BK (dollars/unit voucher).

* Furthermore, the ratio between the value of voucher A and voucher B on day K just happens to be RateK.

On day 3, the value of voucher A and voucher B is 2 / 2, and the ratio between the value is 1, but RateK = 3. I think either sample io or description is wrong (I can't find any other text to rescue this situation)

• (0/0)
According to chinese resource it seems that RateK[x] is the "ratio of amount that exchange center give", so (amount of voucher A given) : (amount of voucher B given) = RateK[x] : 1, regardless of the value of voucher

• (2/0)
For test case 5 you can submit any number within ± a thousandth of correct answer and still get AC, ie. if the answer was 30000 submitting any number in [29970, 30030] would AC

• (0/0)
You're correct; there was an error in the floating point checker. I've fixed it and am in the process of rejudging submissions.

Edit: Rejudging is complete. The only users that was affected was kobortor. I only rejudged submissions that had an impact on a user's points, so I did not re-run your test submission.