Two SigmaOA #1
Maximum Throughput
Estimated MediumJudge-ready
Topics (AI-labelled)Binary SearchGreedy
Scaling up service i once costs cost[i], and after t scale-ups its throughput is tp[i]*(1+t). The throughput of the serial pipeline is the minimum over all services; find the maximum throughput with a total cost not exceeding the budget.
Input
The first line contains n budget, the second line contains n values of tp, and the third line contains n values of cost. Original OCR001/002 gives no numeric bounds; this site uses 1≤n≤100000, 0≤tp≤10^9, 1≤cost≤10^9, and 0≤budget≤10^9. Positive costs explicitly rule out unlimited free scale-ups, and a throughput of 0 can never be increased.
Output
Output one integer answer.
Example 1
Input:
3 32
4 2 7
3 5 6
Output:
10
Example 2
Input:
1 0
2
3
Output:
2
Example 3
Input:
2 10
0 8
1 2
Output:
0
Example notes
The outputs of the three public examples are, in order: 10; 2; 0. They have been checked by independent enumeration or direct simulation.
Editorial
Loading solution…