Gasoline Production
InterviewTime limit2sMemory limit1024 MB
Given n bids with line cost A, per-ton cost B, and price C, find the bid index that minimizes A/(C-B), with ties going to the smallest index.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Nanoneft is holding a tender to equip a new gasoline plant. Suppliers submitted bids for production lines. Each bid gives three integers:
- : the cost of the production line;
- : the cost of producing one ton of gasoline on this line;
- : the price per ton that customers are willing to pay for gasoline produced on this line.
The break-even point is the amount of gasoline that must be produced on the line so that its total sale price equals the line cost plus the production cost. In other words, the break-even amount satisfies , so .
You are the acting manager of Nanoneft and must pick one bid. Choose the bid for which the break-even point requires the smallest amount of gasoline.
Input
The first line contains (), the number of bids. Each of the next lines contains three integers , , (, ).
Output
Print the number of the bid with the smallest break-even point. If several bids are optimal, print the smallest number among them.