PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000047. Trao đổi tiền tệ có phí (Currency Exchange)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Trao đổi tiền tệ có phí (Currency Exchange)
Currency Exchange
Source: POJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are currencies and two-way exchange offices. Exchanging units using rate and commission yields provided the remaining amount is nonnegative. Starting with units of currency , determine whether one can finish with more currency .
Input
First line ; then lines .
Output
Print YES or NO.
Subtasks
- Subtask 1 (20 points): , , ; ; , ; at most two decimal places.
- Subtask 2 (30 points): , , ; ; , ; at most two decimal places.
- Subtask 3 (50 points): , , ; ; , ; at most two decimal places.
Examples
Input
3 2 1 20
1 2 1.00 1.00 1.00 1.00
2 3 1.10 1.00 1.10 1.00
Output
YES
Explanation
Starting with 20 units of currency 1, convert to currency 2 to obtain 19. The conversions yield and then . One more such round yields of currency 2; converting to currency 1 leaves . Thus the answer is YES.