Hide

Problem C
Caber Scoring

In the Highland Games Heavy Events, athletes compete over multiple throwing events and are scored based on their placement in each one. Most of the implements used in the competition have a regulated weight and size, except for the caber, which is used in the caber toss. The caber, whose name comes from the Gaelic word for wooden pole (cabar), is a large tapered wooden tree trunk that athletes must hold straight up, with the smaller end in their hands, and then flip away from themselves so that the larger end hits the ground and the smaller end continues to fall forward until it also hits the ground, at which point the caber is lying still and the toss is complete. This is depicted in Figure 1.

\includegraphics[width=0.75\textwidth ]{cabertoss.jpg}
Figure 1: Side view of a successful caber toss

An athlete’s score is based on the angle of the caber’s final landing position (as viewed from above), and this is specified with reference to the position of the hour hand on an analog clock, using hours and minutes. If the caber lands so that the small end is pointing directly away from the athlete, that is the 12:00 position, which is a perfect toss. The 9:00 and 3:00 positions occur when the orientation of the caber is perpendicular to the line between the athlete and the large end of the caber, to the left or to the right, respectively. The 12:00 position earns a clock score $\textrm{of}~ 1,$ and the 9:00 and 3:00 positions earn a clock score $\textrm{of}~ 0.$ Clock scores scale linearly from $0$ to $1$ as the position moves from 9:00 to 12:00, and similarly as the position moves from 3:00 to 12:00. So, for example, a 1:30 position would result in a $0.5$ clock score, and a 9:36 position would result in a $0.2$ clock score. A position on the lower half of the clock, between 3:01 and 8:59, inclusive, indicates a failed toss, since this means that the caber was not properly flipped over. Figure 2 illustrates three example positions.

\includegraphics[width=0.5\textwidth ]{clock.png}
Figure 2: Cabers landing in positions 9:36, 12:00, and 1:30

Comparing caber toss performance for the same caber is easy since it is a direct comparison of clock scores, but comparing across different competitions using different cabers with varying heights and/or weights is less straightforward, and therefore the overall caber toss score is given by the following formula:

\[ \textit{overall score} = \textit{floor} \left[\, ((5 \times \textit{height}) + \textit{weight}) \times \textit{clock score}\, \right] \]

where height is the height of the caber in feet, weight is the weight of the caber in pounds, and floor is the floor function, which rounds down to the nearest integer. (Actually, the floor function is not used in a real caber toss; it was added to simplify this problem.)

It has been a full season of competitions, and we would like to determine the athlete with the best performance in the caber toss. To do so, you need to calculate and compare the overall scores for all (successful) attempts made by athletes who participated in this event.

Input

The first line of input contains a positive integer, $N$, which is the number of caber toss attempts $(N \leq 1\, 000).$ This is followed by $N$ lines, each of which contains the data for one attempt, given as four space-separated values: the name of the athlete, the height of the caber in feet, the weight of the caber in pounds, and the clock position. An athlete’s name is a non-empty string of characters of maximum length $20.$ Valid characters are lowercase letters (az), digits (09), and underscore (_). No athlete is named “tie” (this is relevant below). The height is a real number in the interval $[10,30],$ and the weight is a real number in the interval $[30,200].$ Both height and weight have exactly one digit after the decimal point. The clock score is given in the form HH:MM, and is always in the upper half of the clock, between 09:00 and 03:00, inclusive. No two athletes have the same name, and a single athlete may have multiple recorded attempts.

To avoid issues related to floating-point precision, no overall score prior to application of the floor function will evaluate to an integer, unless it $\textrm{is}~ 0.$

Output

Output a single line containing the name of the athlete with the best overall score followed by that best score. If there is a tie (more than one athlete has the best score), print the word “tie” followed by the tied best score. If an athlete tied themselves for the best score and no other athlete tied them, print the name of the winning athlete followed by their best score. In each case, separate the name/word and the score with a single space.

Sample Input 1 Sample Output 1
3
highlander_0 21.1 93.0 12:40
highlander_1 18.4 89.3 09:10
eiric 17.3 112.3 10:00
highlander_0 154
Sample Input 2 Sample Output 2
3
lili 18.4 80.0 11:50
muire 18.0 85.0 02:40
ailig 18.4 80.0 12:10
tie 162
Sample Input 3 Sample Output 3
5
lili 18.4 80.0 11:50
muire 18.0 85.0 02:40
ailig 18.4 80.0 12:10
conn 18.4 80.0 12:10
muire 20.0 95.0 12:05
muire 189

Please log in to submit a solution to this problem

Log in