Grouped Boxes With hue
Ironbark Manufacturing compares two teams across several quarters, so each quarter gets a pair of summary boxes side by side. The quarterly note leads on the current quarter only, and it names the team whose middle reading came out higher — the middle rather than the average, because a single outlier shift should not decide which team is named.
Task: Print the team with the higher middle reading in Q1.
Input
The first line holds one integer n, the number of readings. Each of the next n lines holds a quarter label, a team name and one reading, separated by single spaces. Labels and names contain no spaces, and a team may appear on several lines within a quarter.
Output
One line holding a single team name, exactly as it was read. Consider only the readings whose quarter label is Q1; every other quarter is ignored. Within Q1, a team's figure is the middle of its own readings, averaging the two central ones on an even count. If two teams tie, print whichever name comes first alphabetically.
Example:
Input:
4
Q1 Red 10
Q1 Blue 50
Q2 Red 5
Q1 Red 20
Output:
Blue
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