ปานกลาง 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Factory Production Time

Find the earliest time parallel machines can finish a target number of items.

All machines start at time 0 and work independently. A machine with time t finishes one item after t seconds, another after 2t seconds, and so on. Find the earliest whole second when their combined production reaches the target.

Implement factory_machines(times, target).

Input

times: Seconds needed for one item on each machine.

target: The number of completed items required.

Output

Return the minimum elapsed seconds.

เงื่อนไข

1 ≤ machines ≤ 200,000. Each time and the target are between 1 and 1,000,000,000. The answer fits signed 64-bit.

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
times = [2, 3]
target = 5

ผลลัพธ์ที่คาดหวัง:
expected = 6
อินพุต:
std::vector<long long> times = {2, 3};
long long target = 5;

ผลลัพธ์ที่คาดหวัง:
long long expected = 6;
อินพุต:
long[] times = new long[] {2, 3};
long target = 5;

ผลลัพธ์ที่คาดหวัง:
long expected = 6;

คำอธิบาย

At time 6 the machines have made 3 + 2 = 5 items. At time 5 they have made only 2 + 1 = 3.

ตัวอย่างที่ 2
อินพุต:
times = [4]
target = 3

ผลลัพธ์ที่คาดหวัง:
expected = 12
อินพุต:
std::vector<long long> times = {4};
long long target = 3;

ผลลัพธ์ที่คาดหวัง:
long long expected = 12;
อินพุต:
long[] times = new long[] {4};
long target = 3;

ผลลัพธ์ที่คาดหวัง:
long expected = 12;

คำอธิบาย

One machine completes its third item at 3 × 4 = 12 seconds.

แหล่งอ้างอิง

โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก