|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||56||22||19||40.426%|
Kathy is in charge of statistics for the girl’s basketball team at her high school. She meticulously records each basket made and the time it occurred. Her record book for a game might begin as follows:
H 2 0:13 A 2 0:19 H 1 0:52 H 1 0:52 A 3 1:08 ...
This indicates that
The coach is very impressed with all the statistics that Kathy keeps. Using these statistics, he would like to know how long each team was in the lead during the game. For example, if both teams went into an incredible shooting slump after the 1:08 mark in the game and no more baskets were made until the end of the game (32 minutes for a high school game) then the home team would have led for 22 seconds (from 0:13 to 0:19 and from 0:52 to 1:08) and the away team would have led for 30:52 (from 1:08 to 32:00).
Kathy is very proud of how impressed the coach is, but she’s not looking forward to going through each game record to determine how long each team was in the lead. Can you help her?
Input starts with a positive integer n indicating the number of scores in the game. Following this are n lines of the form
T p time where
T is either ’
H’ or ’
p is the number of points scored (either 1, 2 or 3) and
time is the time the points were scored in either the form
m:ss (if the time is less than 10 minutes) or
mm:ss. All times are between 0:00 and 31:59 and given in non-decreasing order.
Display three things: 1) either an ’
H’ or ’
A’ indicating which team won the game, 2) the length of time the home team was leading, and 3) the length of time the away team was leading. Use the form
m:ss for any time less than 10 minutes and
mm:ss otherwise. All games will have a winner.
5 H 2 0:13 A 2 0:19 H 1 0:52 H 1 0:52 A 3 1:08
A 0:22 30:52
1 H 1 16:00
H 16:00 0:00