Dsa
Greedy
Easy
Ceramic Glazing
You have N ceramic pots. Each pot i must first be glazed by a master (takes G[i] minutes) and then fired in a kiln (takes F[i] minutes). You only have one master, so only one pot can be glazed at a time. However, you have an infinite number of kilns, so any number of pots can be fired simultaneously. What is the minimum time required until ALL pots have finished firing?
Input Format:
The first line contains N. The next N lines contain G[i] and F[i].
Output Format:
A single integer representing the total time.
Example:
Input:
2
5 2
2 10
Output:
14
Explanation: If you glaze pot 1 (5 mins) then pot 2 (2 mins), pot 1 finishes firing at 5+2=7, and pot 2 finishes glazing at 7 and firing at 7+10=17. Total 17. If you glaze pot 2 first, pot 2 finishes firing at 2+10=12. Pot 1 finishes glazing at 2+5=7 and firing at 7+2=9. Total max(12, 9) = 12.
Key concepts
greedysortingparallel-processing
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