Auto-Formatting Percentages on the Pie
Calder & Voss is reviewing where a client's revenue comes from. Each wedge is drawn with its own percentage written on top of it, so a reader never has to judge an angle. The concentration risk is what the review is really about: the client's board has a standing rule that any customer group worth more than a quarter of revenue needs a named owner, and the count of those goes under the picture.
Task: Print how many categories are worth strictly more than a quarter of the total. The total is every value in the list added together — do not assume the values already come to 100. A category sitting on exactly a quarter is not more than a quarter and does not count.
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 clear the quarter mark.
Example:
Input:
4
A 40
B 30
C 20
D 10
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