Delivery
Time limit2sMemory limit1024 MB
Each shop costs p plus d plus C times v, and the task is to output the smallest such total over all n shops.
- Level
Easy1 of 10
- Topics
- Implementation, Brute force
- Solved
- No attempts yet
Problem
Ralph wants to buy a very pretty model car as a birthday gift for Vanellope. He found shops that sell this model and numbered them from 1 to . In shop , the model costs points.
Ralph is always busy and has no time to drive to a shop, so he plans to use the delivery service that every shop offers. The delivery fee in shop is points. Fuel for the delivery vehicle is paid separately. Gasoline currently costs points per liter, and the delivery vehicle from shop uses exactly liters to reach Ralph.
Help Ralph find the minimum cost of the model including delivery, over all the shops he found.
Input
The first line contains two integers and , the number of shops and the price of gasoline per liter ().
Each of the next lines contains three integers , , and : the price of the model, the delivery fee, and the liters of gasoline needed for delivery at shop ().
Output
Print one integer, the minimum cost of the model including delivery.