PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000289. Sản xuất nhiều hợp kim nhất (Maximum Number of Alloys)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sản xuất nhiều hợp kim nhất (Maximum Number of Alloys)
Maximum Number of Alloys
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are metal types and machines. Machine consumes units of metal per alloy. Initial stock is , and each additional unit costs . The budget is . Select a single machine for all production; mixing machines is forbidden. Maximize the number of alloys.
Input
First line: . Next k lines: n integers per row. Next line: n stocks . Last line: n costs .
Output
Print the maximum number of alloys.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input 1
3 2 15
1 1 1
1 1 10
0 0 100
1 2 3
Output 1
5
Explanation
Machine 2 makes five alloys for cost 15, using 50 units of metal 3 from stock. Six alloys already require cost 18 for metals 1 and 2 alone.