404773: GYM101628 J Jenny and the Batteries

Memory Limit:64 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Jenny and the Batteriestime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

Jenny works at BBB (Battery Bank of Brazil). She's in charge of optimizing the batteries' displacements, but can't solve the problem. Knowing you are a programmer, she asked for your help.

At BBB, the batteries are arranged in piles. In a bank, the batteries can't be discharged. So, when recharging then, the bank spends M energy units, where M is the size of the greatest pile. Each pile initially has ai batteries.

There is a machine the can move a battery from pile i to pile j with cost bi + cj. Jenny has a limited budget of K for moving the batteries and the bank wants the minimum M possible at the end.

Input

The first line of input consists of the integers N and K (1 ≤ N ≤ 105, 1 ≤ K ≤ 1018). The following N lines contain ai, bi and ci (0 ≤ ai, bi, ci ≤ 106).

Output

Print the minumum M possible.

ExampleInput
5 20
5 3 8
2 8 3
3 2 4
7 2 1
6 1 1
Output
5

加入题单

上一题 下一题 算法标签: