This page is still under construction.

Parts of this page are still being built. What you see may change.

Funfair

Time limit2sMemory limit512 MB

Summary
Pick and order k games from n so the expected final money is maximized, then report that value.
Level

Medium7 of 10

Topics
Dynamic programming, Sorting, Probability
Solved
No attempts yet

Problem

A funfair has games G1,G2,…,GnG_1, G_2, \dots, G_n. You pick kk of them and play each picked game once, in an order of your choice. You cannot play the same game twice, and you must fix both the kk games and their order before the first game starts.

You start with x0x_0 Oshloobs. Suppose you hold xx Oshloobs when game GiG_i begins. If you win it, your money becomes x+Aix + A_i. If you lose it, you lose LiL_i percent of xx, so your money becomes x×(1−Li/100)x \times (1 - L_i / 100). You win game GiG_i with probability PiP_i percent, and the games are independent of each other.

Choose the kk games and their order so that the expected amount of money you hold after playing all of them is as large as possible, and report that expected amount.

Input

The input holds several test cases.

The first line of each test case has three space separated integers nn, kk, and x0x_0 (1≤k≤n≤1001 \le k \le n \le 100, 0≤x0≤1060 \le x_0 \le 10^6). Each of the next nn lines describes game GiG_i with three space separated integers AiA_i, LiL_i, and PiP_i (0≤Ai,Li,Pi≤1000 \le A_i, L_i, P_i \le 100).

The last line of the input is 0 0 0. It is not a test case, so do not process it.

Output

For each test case, print on one line the maximum expected amount of final money, rounded to exactly two digits after the decimal point. Always print both digits.

A value exactly halfway rounds up, so 1.0051.005 prints as 1.01. Every answer in the test data is farther than 10−410^{-4} from a halfway point, so double precision arithmetic gives the same digits.

Examples3

  1. Example 1

    Input
    2 2 100
    10 0 50
    100 10 20
    2 1 100
    10 0 50
    100 10 20
    0 0 0
    
    Expected output
    117.00
    112.00
    
  2. Example 2

    Input
    3 2 1000
    0 50 50
    60 20 100
    100 0 30
    0 0 0
    
    Expected output
    1090.00
    
  3. Example 3

    Input
    1 1 0
    100 0 37
    1 1 1000000
    0 100 0
    0 0 0
    
    Expected output
    37.00
    0.00