Under construction

Still being built. Things may change

Production System Management

Interview

Time limit1sMemory limit512 MB

Summary
Given N jobs whose success probability rises with each extra machine, buy machines within budget B to maximize the product of all success probabilities.
Level

Medium5 of 10

Topics
Dynamic programming, Implementation
Solved
No attempts yet

Problem

In the land of the winter forest, a production system is made up of NN kinds of jobs. The goal is for every job in this system to work correctly.

Job ii is carried out by running machine ii. When there is one machine ii, the probability that job ii works correctly is pi/100p_{i} / 100. Each additional machine ii purchased raises that probability by ai/100a_{i} / 100. However, no matter how many machines ii are bought, the probability that job ii works correctly cannot exceed 11.

For example, suppose there are jobs 1 and 2 with p1=40p_{1} = 40, p2=60p_{2} = 60, a1=15a_{1} = 15, and a2=10a_{2} = 10. When there is one machine each for machines 1 and 2, the probability PP that every job works correctly is 0.4×0.6=0.240.4 \times 0.6 = 0.24. However, if you buy 2 more of machine 1 and 1 more of machine 2, giving 3 and 2 machines in total, PP improves to (0.4+0.15×2)×(0.6+0.1×1)=0.49(0.4 + 0.15 \times 2) \times (0.6 + 0.1 \times 1) = 0.49. If machine ii costs cic_{i}, how can PP be maximized with total cost at most BB?

Initially, there is one machine of each kind.

Input

The first line contains an integer NN (1≤N≤91 \leq N \leq 9), the number of job types, and an integer BB (0≤B≤30,0000 \leq B \leq 30,000), the budget.

The next NN lines each contain integers pip_{i}, aia_{i}, and cic_{i} separated by spaces. (1≤pi,ai≤991 \leq p_{i}, a_{i} \leq 99, 1≤ci≤30,0001 \leq c_{i} \leq 30,000)

Output

On the first line, print the maximum possible value of PP multiplied by 102N10^{2N}, using a total cost of at most BB. This value is always an integer.

On the second line, print the number of additional machines to buy for each machine ii in order, separated by spaces.

If there are several ways, print any of them.

Examples3

  1. Example 1

    Input
    2 450
    40 15 200
    60 10 150
    
    Expected output
    4200
    2 0
    
  2. Example 2

    Input
    2 1750
    40 13 200
    60 9 150
    
    Expected output
    10000
    5 5
    
  3. Example 3

    Input
    2 0
    40 13 200
    60 9 150
    
    Expected output
    2400
    0 0