#abc374e. E - Sensor Optimization Dilemma 2
E - Sensor Optimization Dilemma 2
Score : points
问题陈述
制造某种产品需要个流程,编号为。
对于每个流程,有两种类型的机器和可供购买以处理它。
- 机器:每台每天可以处理个产品,每台成本为日元。
- 机器:每台每天可以处理个产品,每台成本为日元。
你可以购买每种机器的任意数量,可能是零。
假设流程由于引入机器,每天可以处理个产品。 在这里,我们定义生产能力为的最小值,即。
给定总预算为日元,找出可实现的最大生产能力。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
The manufacturing of a certain product requires processes numbered .
For each process , there are two types of machines and available for purchase to handle it.
- Machine : Can process products per day per unit, and costs yen per unit.
- Machine : Can process products per day per unit, and costs yen per unit.
You can purchase any number of each machine, possibly zero.
Suppose that process can handle products per day as a result of introducing machines.
Here, we define the production capacity as the minimum of , that is, .
Given a total budget of yen, find the maximum achievable production capacity.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3 22
2 5 3 6
1 1 3 3
1 3 2 4
Sample Output 1
4
For example, by introducing machines as follows, we can achieve a production capacity of , which is the maximum possible.
- For process , introduce units of machine .
- This allows processing products per day and costs a total of yen.
- For process , introduce unit of machine .
- This allows processing product per day and costs a total of yen.
- For process , introduce unit of machine .
- This allows processing products per day and costs a total of yen.
- For process , introduce units of machine .
- This allows processing products per day and costs a total of yen.
Sample Input 2
1 10000000
100 1 100 1
Sample Output 2
1000000000
Sample Input 3
1 1
1 10000000 1 10000000
Sample Output 3
0
There may be cases where a positive production capacity cannot be achieved.
Sample Input 4
10 7654321
8 6 9 1
5 6 4 3
2 4 7 9
7 8 9 1
7 9 1 6
4 8 9 1
2 2 8 9
1 6 2 6
4 2 3 4
6 6 5 2
Sample Output 4
894742
相关
在下列比赛中: