Dsa
Heap
Hard
Orderly Pizza Delivery
You are managing a pizza delivery service. Each pizza is assigned a delivery time based on its preparation time and the distance to the delivery location. The pizzas are delivered in the order of their delivery times. You will receive a list of pizzas with their preparation times and distances, and your task is to output the delivery order based on the calculated delivery times (delivery time = preparation time + distance). If two pizzas have the same delivery time, they should be delivered in the order they were received.
Input Format:
The first line contains an integer n (1 <= n <= 10^5), the number of pizzas.
The next n lines each contain two integers p (0 <= p <= 100) and d (0 <= d <= 100), representing the preparation time and distance of each pizza.
Output Format:
For each pizza, print the index (1-based) in the order they should be delivered.
Example:
Input:
3
2 3
1 4
2 2
Output:
2
1
3
Key concepts
heappriority_queuesorting
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