← 返回 uber 的题目列表Pipeline Throughput Maximization Under Budget (Binary Search)
类型:online_judge
Problem: Maximize Serial Pipeline Throughput Under Budget
You have a serial pipeline consisting of n services. Service i has base throughput t[i].
Because the pipeline is serial, overall throughput is the minimum throughput across services:
throughput = min_i throughput_i
You may scale each service. If you scale service i by x times (x is a non-negative integer), its throughput becomes:
throughput_i = t[i] * (1 + x)
The cost of scaling service i by x is:
cost_i(x) = x * c[i]
Given a total budget B, compute the maximum achievable overall pipeline throughput (output an integer).
Input Format
Line 1: integer n
Line 2: n integers t[i]
Line 3: n integers c[i]
Line 4: integer B
Output
One line: the maximum achievable overall throughput (integer).
Constraints
1 <= n <= 2e5
1 <= t[i], c[i] <= 1e9
0 <= B <= 1e18
Example
Input:
3
5 2 4
3 10 2
20
Output:
6
(Example for illustration; exact value depends on feasibility check.)
Example
Input
3
5 2 4
3 10 2
0
Output
2