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- series, in which the first team to
win
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
games, and no further games are played after that point. This means that
the series may last between
and
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 game, Team
will score
points and Team
will score
points
.
In fact, you have these values for all
potential games in the series,
even though the
,
, and/or
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 of which consists of two
space-separated integers,
and
(for
).
Output Specification
Output two space-separated integers, the number of games won by Teams
and
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 game, Team
has won
games (games
and
), while Team
has won the remaining
(games
,
,
, and
). Because Team
has just
reached a total of
games won, the series ends. Note that the potential
scores for game
are included in the input, but aren't considered
because that game doesn't end up getting played.
Comments