#P7632. [COCI 2010/2011 #5] KOŠARKA

[COCI 2010/2011 #5] KOŠARKA

Description

Slavko has started following the NBA. A game lasts exactly 4848 minutes. After a game ends, statistics are shown. Every time a team scores, Slavko writes it down. He is curious about how long each team stays in the lead.

Input Format

The input consists of NN lines.

The first line contains an integer NN, the number of events.

The next NN lines describe the moments when a team scores.

Each line contains the team that scored (11 or 22) and a time.

The time format is MM:SSMM:SS. If the minutes or seconds are 9\le 9, they are padded with a leading 00.

Output Format

The first line outputs the total time during which Team 11 is in the lead.

The second line outputs the total time during which Team 22 is in the lead.

All durations should be in MM:SSMM:SS format, with leading zeros.

1
1 20:00 
28:00
00:00 

3
1 01:10
2 21:10
2 31:30 
20:00
16:30 
5
1 01:10
1 02:20
2 45:30
2 46:40
2 47:50 
45:30
00:10 

Hint

Sample Explanation #1

Team 11 scores a point at exactly 2020 minutes, making the score 1:01:0, and takes the lead.

During the next 2828 minutes, Team 22 does not score, so Team 11 keeps the lead the whole time.

Constraints

For 100%100\% of the testdata, 1N1001 \le N \le 100, 00 \le minutes 47\le 47, 00 \le seconds 59\le 59.

Notes

The score for this problem follows the original COCI settings, with a full score of 5050.

Translated from COCI2010-2011 CONTEST #5 T2 KOŠARKA.

Translated by ChatGPT 5