Comparing Two Trend Lines
Alderwood Supply sells two competing own-brand products and charts both on one pair of axes, month by month, so the buyer can see where one overtook the other. Under the chart the pack names the product that sold more in total across the whole period — not the one leading at the end, and not the one leading in most months. If the two products come to exactly the same total, the pack names B.
Task: Print which product sold more in total, A or B.
Input
The first line holds an integer n, the number of months. Each of the next n lines holds a month name, that month's sales of product A and that month's sales of product B, separated by single spaces. Months arrive in order and a name contains no spaces.
Output
One line holding either A or B, a single capital letter.
Example:
Input:
3
Jan 10 20
Feb 15 18
Mar 20 15
Output:
B
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