P7203 [COCI 2019/2020 #3] Turnaround (Preokret)

Background

One day after Christmas, St. Stephen’s Day is coming. In non-religious contexts, it is called Boxing Day in the UK. While Croatians celebrate by enjoying a big meal, our British friends have a tradition of playing football. This Christmas, Pep ate too much roast beef, so he decided not to play football this time, but to stay at home and analyze the match.

Description

There are $N$ 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 $N$ mentioned in the statement. The next $N$ lines each contain an integer $1$ or $2$. $1$ means City scores, and $2$ 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”.

Explanation/Hint

#### Sample Explanation Explanation of the first sample: The $6$ scores are: `0:0`, `1:0`, `2:0`, `2:1`, `2:2`, `2:3`. Among them, there are $2$ ties: `0:0` and `2:2`. The largest “turnaround” is when City’s opponent was behind `2:0`, but then scored $3$ more goals, making the score `2:3`, and surpassed City. Explanation of the second sample: The $10$ 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 $3$ ties: `0:0`, `1:1`, and `2:2`. The largest “turnaround” is when City was behind `1:2`, but then scored $3$ more goals, making the score `4:3`, and surpassed the opponent. #### Constraints For $100\%$ of the testdata, $1 \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 $1$ point, and the third line is worth $3$ points, so a Special Judge is used. #### Notes **The scoring of this problem follows the original COCI problem setting, with a full score of $50$.** This problem uses an unofficial [Special Judge](https://www.luogu.com.cn/paste/zfwv9rik). You are welcome to hack it (via private message or by posting directly). **Translated from [COCI2019-2020](https://hsin.hr/coci/archive/2019_2020/) [CONTEST #3](https://hsin.hr/coci/archive/2019_2020/contest3_tasks.pdf) _T1 Preokret_.** Translated by ChatGPT 5