#P7203. Comeback in Football Match

    ID: 20407 Type: Default 1000ms 256MiB

Comeback in Football Match

Comeback in Football Match

In a football match, City and its opponent score goals in a given order. Based on the scoring sequence, answer the following questions:

  1. What is the final score of the match, i.e. the goals scored by City and its opponent?
  2. How many times was the game tied (a tie is counted whenever the scores are equal, including the starting score $0:0$)?
  3. What is the size of the largest comeback? Here, a comeback is defined as a situation where a team, while trailing (i.e. its score is strictly less than that of the opponent prior to a series of consecutive goals), scores consecutively such that after the series its score exceeds that of the opponent. It is guaranteed that at least one comeback exists.

inputFormat

The input consists of two lines. The first line contains an integer NN (N1N \ge 1), the number of goals scored. The second line contains NN space-separated characters. Each character is either 'C' (indicating a goal by City) or 'O' (indicating a goal by the opponent).

outputFormat

Output four integers separated by spaces: the final score of City, the final score of the opponent, the number of times the match was tied (including the initial 0:00:0), and the largest comeback (i.e. the maximum number of consecutive goals that turned a trailing situation into a lead).

sample

5
C O O O C
2 3 2 3