All problems

Reading the Elbow Plot

mediumPythonK-Means Clustering

Wexford Couriers has run the whole exercise at several different locker counts and recorded the total charge each one produced. Adding lockers always drives the charge down, so the lowest charge is never the answer -- taken to its conclusion it means one locker per customer. What the planners want is the count where the charge fell hardest against the count listed immediately before it, the point after which extra lockers stop earning their keep. Only the row directly above counts, and the fall is a plain difference in charge, never a proportion of it. The counts on the list are not always consecutive.

Task: Print the locker count the planners pick.

Input

The first line holds one integer n, the number of rows. Each of the next n lines holds a locker count and the total charge it produced, separated by a single space, listed with the counts increasing.

Output

One line holding the word k, a single space, and the chosen locker count -- the later of the two rows that the biggest fall sits between. If two falls are exactly equal, print the smaller of the counts they point to.

Example:

Input:
4
1 100
2 40
3 35
4 33

Output:
k 2

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…