Logo
(追記) (追記ここまで)

17340번 - Cash Exchange 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB606612.766%

문제

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 amount 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:

Time AK BK RateK
Day 1 1 1 1
Day 2 1 2 2
Day 3 2 2 3

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:

Time Transaction Cash (Dollars) Voucher A Voucher B
Initial None 100 0 0
Day 1 Buy – 100 dollars 0 50 50
Day 2 Sell – 50% 75 25 25
Day 2 Buy – 60 dollars 15 55 40
Day 3 Sell – 100% 205 0 0

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.

입력

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 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.

제한

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

예제 입력 1

3 100
1 1 1
1 2 2
2 2 3

예제 출력 1

225.000

힌트

출처

Olympiad > National Olympiad in Informatics (China) > NOI 2007 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /