WC '17 Contest 1 J3 - Stanley

View as PDF

Submit solution


Points: 3
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
Woburn Challenge 2017-18 Round 1 - Junior Division

This is it - the exciting finals of the Stanley Cup playoffs are about to begin! The format is a best-of-7 series, in which the first team to win 4 games will claim the Cup!

In each game, the team which scores more points than the other team wins (there are no ties). The series ends as soon as one team has won 4 games, and no further games are played after that point. This means that the series may last between 4 and 7 games, inclusive.

By collecting data on all hockey games which have ever been played, and performing some sophisticated data analysis, you've managed to predict all of the upcoming games' scores with absolute certainty. You know that, in the i^{th} game, Team A will score A_i points and Team B will score B_i points (0 \le A_i, B_i \le 10, A_i \ne B_i). In fact, you have these values for all 7 potential games in the series, even though the 5^{th}, 6^{th}, and/or 7^{th} games may not actually get played, in which case their scores should be ignored.

All that's left is to place your bets on the winning team. You can rake in even more cash if you bet on the exact final game counts. As such, given your predicted scores, determine the number of games won by each of the teams when the series ends.

Input Specification

The input consists of seven lines, the i^{th} of which consists of two space-separated integers, A_i and B_i (for i = 1 \dots 7).

Output Specification

Output two space-separated integers, the number of games won by Teams A and B respectively when the series ends.

Sample Input

5 3
4 1
1 5
1 4
0 6
0 2
3 1

Sample Output

2 4

Sample Explanation

After the 6^{th} game, Team A has won 2 games (games 1 and 2), while Team B has won the remaining 4 (games 3, 4, 5, and 6). Because Team B has just reached a total of 4 games won, the series ends. Note that the potential scores for game 7 are included in the input, but aren't considered because that game doesn't end up getting played.


Comments

There are no comments at the moment.