#P4058. [Code+#1] 木材

[Code+#1] 木材

Description

There are nn trees. Initially, the ii-th tree has height HiH_i, and every month the ii-th tree grows by AiA_i. There is an order for a total timber length of SS. The client requires each piece of timber to have length at least LL, and each piece must be a whole tree (i.e., you cannot take only part of a tree). What is the minimum number of months you need to wait to fulfill the order?

Input Format

The first line contains 33 non-negative integers nn, SS, LL separated by spaces, denoting the number of trees, the total required length, and the minimum length for a single piece, respectively.

The second line contains nn non-negative integers H1,H2,,HnH_1, H_2, \ldots, H_n.

The third line contains nn non-negative integers A1,A2,,AnA_1, A_2, \ldots, A_n.

Output Format

Output a single integer on one line representing the answer.

3 74 51
2 5 2
2 7 9

7

Hint

For the sample, after six months, the heights of the trees are 1414, 4747, 5656, and the order cannot be fulfilled.

After seven months, the heights are 1616, 5454, 6565. You can then cut down the 22-nd and 33-rd trees to fulfill the order.

From CodePlus 2017 November Contest, proudly presented by the Student Association for Algorithms and Competitions, Department of Computer Science and Technology, Tsinghua University.

Credit: idea/Zheng Linkai, problem setter/Zheng Linkai, tester/Wang Yuzhong.

Git Repo: https://git.thusaac.org/publish/CodePlus201711

Thanks to Tencent for supporting this contest.

Translated by ChatGPT 5