Dsa
Queue
Easy
The Production Pipeline
A factory line has three sequential robots: A, B, and C. Every part must be processed by A, then B, then C. Each robot can only work on one part at a time. A part can only move to the next robot's queue once the current robot finishes. Given the arrival times of N parts at robot A and the time each robot takes (Ta, Tb, Tc), calculate when the last part finishes robot C.
Input Format:
Line 1: Ta Tb Tc (processing times for each robot)
Line 2: Arrival times of N parts (sorted integers)
Output Format:
A single integer representing the completion time of the final part.
Example:
Input:
2 2 2
0 1
Output:
8
Explanation: Part 1: A(0-2), B(2-4), C(4-6). Part 2: A(2-4) because A was busy until 2, B(4-6) because B was busy until 4, C(6-8) because C was busy until 6.
Key concepts
queuesimulation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now