#P7308. Futuristic Basketball Scoring Analysis
Futuristic Basketball Scoring Analysis
Futuristic Basketball Scoring Analysis
In a futuristic basketball game between team A and team B, the game lasts for \(4 \times 12\) minutes (i.e. 2880 seconds) and scoring events occur at specific seconds (with at most one event per second). Each scoring event records the team that scored, the exact time in seconds, and the number of points scored. The first half of the game is the first 24 minutes (i.e. 1440 seconds).
King James wants answers to the following two questions:
- What is the total number of points scored in the first half?
- How many lead reversal events occurred? A lead reversal is defined as an event where a team that was strictly trailing (i.e. had fewer points than its opponent) scores and, as a result, its total points become strictly greater than the opponent's.
You are given the scoring events in chronological order. Note: Initially, both teams have 0 points.
inputFormat
The input begins with a line containing a single integer \(n\) (the number of scoring events). Each of the following \(n\) lines contains a scoring event in the format:
Team Time Points
where:
Team
is a character either 'A' or 'B' indicating the scoring team.Time
is an integer representing the time in seconds when the event occurred (\(0 < Time \le 2880\)).Points
is an integer indicating how many points were scored in that event.
The events are given in chronological order and no two events occur at the same second.
outputFormat
Output two integers separated by a space:
- The total number of points scored in the first half (i.e. events occurring at or before 1440 seconds).
- The number of lead reversal events throughout the game.
sample
4
A 100 2
B 200 3
A 1500 2
B 2500 2
5 3