MathWorksOA #8
Alloy Production
Estimated MediumJudge-ready
Topics (AI-labelled)Binary Search
合金 1 単位を作るには、金属 i が composition[i] 単位必要です。すでに stock[i] を持っていて、単価 cost[i] でさらに購入でき、予算は budget です。作れる合金の最大単位数を求めてください。
入力
1 行目に n budget、続く 3 行にそれぞれ composition、stock、cost が与えられます。このサイトが追加した制約は 1≤n≤100000、0≤budget≤10^9、1≤composition[i],cost[i]≤10^9、0≤stock[i]≤10^9 です。
出力
合金の最大単位数を出力します。
例 1
入力:
2 3
1 2
0 1
1 1
出力:
1
例 2
入力:
1 0
2
10
4
出力:
5
例 3
入力:
2 5
1 1
0 0
2 3
出力:
1
Editorial
Loading solution…