
83  ZOJ Monthly, September 2009  I
DD and his girlfriend love travelling, one day they go to a strange cave. DD suddenly found some valuable stones and water named "wistone" and "owenwater". If DD could take them to the outer world, he could earn a lot:) Unfortunately, DD only takes a bottle with capacity W with him. He can only use this bottle to take them back. As you know, each type of "wistone" and "owenwater" has different value, and "wistone" cannot be divided into smaller ones while "owenwater" can be taken as much as you want if it is avaliable. Now, you are asked to calculate the maximum value DD can take back. Input This problem contains several test cases, you should process it to the end of input. For each test case, there are two integers in the first line, N (1 <= N <= 100) and W ( 0 <= W <= 50000), N indicates the total type number of "wistone" and "owenwater". W indicates the capacity of bottle. Then next n lines, each line contains three integers, a_{i}, b_{i} (1 <= a_{i}, b_{i} <= 1000) and t_{i}. a_{i} indicates the amount, b_{i} indicates the total value and if t_{i} is 0, it means this one is "wistone" otherwise it is "owenwater". Output For each test case, you should only output one number(accurate to 2 digits to the right of the decimal point), namely the maximum value DD can get. Sample Input 3 150 100 100 0 100 100 0 130 10 1 Sample Output 103.85 Author: WANG, Naiyan Source: ZOJ Monthly, September 2009 