UberOA #56
Pipeline Throughput Maximization Under Budget
Estimated MediumJudge-ready
Topics (AI-labelled)Binary SearchGreedy
Scaling service i up x times costs x×cost[i] and changes its throughput to base[i]×(1+x), where x is a non-negative integer. The throughput of a serial pipeline is the minimum over all services. Find the maximum throughput within the total budget.
This site has made the standard input and output explicit.
Input
The first line contains n budget, the second line contains base, and the third line contains cost. On this site 1≤n≤100000, 1≤base[i],cost[i]≤10⁹, 0≤budget≤10⁹.
Output
Output one integer, the answer.
Example 1
Input:
3 0
5 2 4
3 10 2
Output:
2
Example 2
Input:
3 20
5 2 4
3 10 2
Output:
4
Example 3
Input:
1 5
3
2
Output:
9
Example notes
Example 1: with no budget, the bottleneck is 2. Example 2: throughput 4 needs a budget of 10; throughput 5 needs 22, which exceeds 20, so the maximum is 4, and the budget does not have to be spent completely. Example 3: at most two scale-ups, giving throughput 3×3=9.
Editorial
Loading solution…