#P7203. [COCI 2019/2020 #3] Preokret

[COCI 2019/2020 #3] Preokret

Description

There are NN goals scored and their order is known. He wants to get the answers to the following questions:

  1. What is the final score, i.e., the number of goals scored by City and by their opponent.

  2. How many times during the match was the game tied, i.e., the two teams had the same number of goals. The initial score 0:0 also counts as a tie.

  3. The largest “turnaround”. A “turnaround” means that one team, while being behind, scores consecutive goals and ends up leading the opponent. He wants to know how many goals that team scored in that consecutive run. The testdata guarantees that there is at least one “turnaround”.

Input Format

The first line contains the integer NN mentioned in the statement.

The next NN lines each contain an integer 11 or 22. 11 means City scores, and 22 means their opponent scores.

Output Format

On the first line, output two integers separated by a space, representing the number of goals scored by City and by their opponent.

On the second line, output the number of ties.

On the third line, output the largest “turnaround”.

5
1
1
2
2
2
2 3
2
3
9
1
2
2
1
1
1
2
1
1
6 3
3
3
3
2
1
1
2 1
2
2

Hint

Sample Explanation

Explanation of the first sample:

The 66 scores are: 0:0, 1:0, 2:0, 2:1, 2:2, 2:3. Among them, there are 22 ties: 0:0 and 2:2. The largest “turnaround” is when City’s opponent was behind 2:0, but then scored 33 more goals, making the score 2:3, and surpassed City.

Explanation of the second sample:

The 1010 scores are: 0:0, 1:0, 1:1, 1:2, 2:2, 3:2, 4:2, 4:3, 5:3, 6:3. Among them, there are 33 ties: 0:0, 1:1, and 2:2. The largest “turnaround” is when City was behind 1:2, but then scored 33 more goals, making the score 4:3, and surpassed the opponent.

Constraints

For 100%100\% of the testdata, 1N2501 \le N \le 250.

Scoring

In this problem, each test point is scored by lines. The first line and the second line are both worth 11 point, and the third line is worth 33 points, so a Special Judge is used.

Notes

The scoring of this problem follows the original COCI problem setting, with a full score of 5050.

This problem uses an unofficial Special Judge. You are welcome to hack it (via private message or by posting directly).

Translated from COCI2019-2020 CONTEST #3 T1 Preokret.

Translated by ChatGPT 5