Pizza Delivery

Limits: 1s, 256 MB

Chef Jami had recently started home delivery service for pizzas. Jami has only a single delivery boy that delivers the order by riding his bicycle. Today Chef Jami received N pizza order, the house of the person that ordered the ith pizza needs Ai unit time to prepare and the order is Bi km away from the restaurant. The delivery boy cannot deliver more than one order at a time and takes 1 unit time per km. Therefore, after delivering an order, he must return back to the restaurant to take the next order. It takes the delivery man no time to get back to the restaurant and the Chef can continue cooking without waiting for the delivery man to come for the next order. The delivery boy is a lazy person and does not want to spend much time in the delivery process, so he wants your help in prioritizing the orders so that he can deliver all orders in least amount of time.

This is a companion discussion topic for the original entry at