영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
The year 2022 has been marked by a series of sensational news topics, one of which is the very high electricity prices in southern Sweden. For Leah, who lives in a villa in Skåne, this unfortunately means that her bitcoin mining is currently not quite paying off due to electricity costs. However, something trivial as this will not stop her. Energy is ultimately just energy, and electricity can just as well be obtained by burning wood!
Leah has a forest with N trees that she plans to cut down to make firewood. The i-th of these trees grows at a rate of v_i nanometers per second and currently has a length of l_i nanometers. After t_i seconds, the tree also becomes too old and stops growing.
Leah needs firewood from trees whose total length is S nanometers to be able to power her bitcoin mining for a year, but she is unsure if the trees can grow to that length quickly enough. Can you calculate how many seconds it will take before the lengths of Leah's trees have at least a total of S nanometers?
Input
The first line of input contains the integers N (1 ≤ N ≤ 200,000), the number of trees in Leah's forest, and S (1 ≤ S ≤ 10^9), the total length of trees Leah needs.
The following N lines describe her trees. The i-th line contains the three integers l_i (0 ≤ l_i ≤ 10^9), v_i (0 ≤ v_i ≤ 10^9), and t_i (0 ≤ t_i ≤ 10^9), as described earlier.
It is guaranteed that the forest will have sufficient length for Leah at some point.
Output
Print the smallest integer k, such that after k whole seconds, Leah's forest has sufficient total length.
Scoring
Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.
| Group | Points | Constraints |
|---|---|---|
| 1 | 16 | N = 1 |
| 2 | 17 | N ≤ 1000, S ≤ 1000 |
| 3 | 17 | N ≤ 1000 |
| 4 | 50 | No additional constraints. |
예제
예제 1
1 5 2 1 3
3
예제 2
3 30 4 4 2 1 1 10 2 3 5
4
예제 3
1 10 11 1 1
0