P29554 [洛谷] [COCI2019-2020#3] Preokret
普及
题目描述

Problem Description

On the day after Christmas, known as St. Stephen's Day, which is also called Boxing Day in the UK, while Croatians celebrate with a feast, our British friends have a tradition of playing football.

This Christmas, Pep ate too much roast beef, so he decided not to play football but instead analyze a match at home.

Problem Description

Given \( N \) goals scored in sequence, Pep wants to answer the following questions:

  1. What is the final score, i.e., the number of goals scored by City and their opponent.
  2. How many times the match was tied, i.e., when both teams had the same number of goals. The initial score of 0:0 is also considered a tie.
  3. The largest "comeback." A "comeback" refers to a situation where one team, after being behind in the score, scores consecutively to take the lead. He wants to know the number of goals scored by that team. It is guaranteed that there is at least one "comeback."

Input Format

The first line contains the integer \( N \) as mentioned in the problem.

The next \( N \) lines each contain an integer, either \( 1 \) or \( 2 \). \( 1 \) represents a goal scored by City, and \( 2 \) represents a goal scored by their opponent.

Output Format

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

The second line should output the number of times the match was tied.

The third line should output the largest "comeback."

Sample Input and Output

Sample Input #1

5
1
1
2
2
2

Sample Output #1

2 3
2
3

Sample Input #2

9
1
2
2
1
1
1
2
1
1

Sample Output #2

6 3
3
3

Sample Input #3

3
2
1
1

Sample Output #3

2 1
2
2

Notes

Sample Explanation

For the first sample:

The scores after each of the 6 goals are: 0:0, 1:0, 2:0, 2:1, 2:2, 2:3. There are 2 ties — 0:0 and 2:2. The largest "comeback" is when City's opponent was behind 2:0 but scored 3 consecutive goals to lead 2:3.

For the second sample:

The scores after each of the 10 goals are: 0:0, 1:0, 1:1, 1:2, 2:2, 3:2, 4:2, 4:3, 5:3, 6:3. There are 3 ties — 0:0, 1:1, and 2:2. The largest "comeback" is when City was behind 1:2 but scored 3 consecutive goals to lead 4:3.

Data Constraints

For \( 100\% \) of the data, \( 1 \le N \le 250 \).

Scoring

In this problem, each test case is scored per line. The first and second lines are worth 1 point each, and the third line is worth 3 points, thus enabling a Special Judge.

Notes

This problem's score is set according to the original COCI contest, with a maximum score of 50.

This problem uses an unofficial Special Judge, and you are welcome to hack it (either via private message or by posting).

The problem is translated from COCI2019-2020 CONTEST #3 T1 Preokret.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 1 1 2 2 2
样例输出
2 3 2 3