All problems

Grouping Tiny Slices Into 'Other'

hardPythonMatplotlibPie Chart

Calder & Voss has a client whose sales spread across a long tail of tiny product lines. Drawn as they are, the circle sprouts a fringe of slivers too thin to label and the picture becomes useless. House style is therefore to sweep the small lines together into one wedge called Other before drawing anything. The review needs to know how much sweeping happened, because a wedge hiding twenty lines means something different from one hiding two.

Task: Print how many categories were swept into Other. A category is swept when it is worth strictly less than a tenth of the total; one worth exactly a tenth is kept as its own wedge. The total is every value in the list added together, taken before any sweeping.

Input

The first line holds an integer n, the number of categories. Each of the next n lines holds a category name, one word with no spaces, then its value, separated by a single space. Values may have decimals. n is at least 1.

Output

One line holding a whole number: how many categories were swept together. If nothing was swept, print 0.

Example:

Input:
4
Big 70
Med 20
Small1 5
Small2 5

Output:
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…