The Most Likely Culprit Among Three Machines
Kestrel Manufacturing has brought a third line online, and the shop floor has got harder to reason about. Another defective hub has come back from a customer with no line marking on it at all, and the supervisor has time to strip down exactly one machine tonight. She wants the one most likely to have produced this particular hub.
The awkward part is that the busiest line and the sloppiest line are no longer the same line, so neither column decides it on its own. The floor is rebalanced every quarter, so the shares and the defect rates both come in with the question rather than being fixed.
Each line is described by a share — the fraction of all production that comes off that machine — and a defect_rate, the fraction of that machine's own output that comes off defective. Every hub comes off one of the listed lines, the shares add to 1, and exactly one machine is strictly the most likely, so there is no tie to break.
Task: Print the name of that machine — the bare name, with no quotes and nothing else on the line.
Input
The first line holds one integer n, the number of production lines (2 to 20). Each of the next n lines describes one machine as three fields separated by single spaces: its name, its share, and its defect rate. Names contain no spaces; shares and defect rates are decimals between 0 and 1.
Output
One line holding the name of the most likely machine, exactly as it appeared in the input.
Example:
Input:
3
M1 0.5 0.01
M2 0.3 0.03
M3 0.2 0.05
Output:
M3
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in