Choosing k by Validation Accuracy
Marlow Utilities has to settle how many past faults the dispatcher's shortlist should hold. Nobody could argue it out, so the team ran a trial: they hid a month of faults from the system, tried several shortlist sizes against that hidden month, and wrote down the share each size got right. Where two sizes scored exactly the same the team prefers the smaller, since a shorter shortlist is cheaper to consult and easier to defend to a regulator.
Task: Print the shortlist size that scored best in the trial.
Input
The first line holds n, how many sizes were tried. Each of the next n lines holds a size followed by the share it got right, separated by a space. The size is a whole number; the share is a decimal between 0 and 1. The sizes may appear in any order.
Output
One line holding the letter k, a single space, and the winning size — for example k 7. Print the size as a whole number. If two or more sizes tie on the best share, print the smallest of them, whatever order the lines were in.
Example:
Input:
3
1 0.80
3 0.90
5 0.85
Output:
k 3
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