Problem list
Log in
#r03613 · CCC 2025 Junior

Sunny Days

Gold V 2.0 s 256 MB

There is a large amount of historical weather data for CEMCity. Each day in the data is listed as either a day with sunshine or a day with precipitation. Jeremy is interested in finding the record for the most consecutive days with sunshine. Unfortunately, the data is incorrect for exactly one day, but Jeremy doesn’t know which day this is.

Your job is to help Jeremy determine the maximum possible number of consecutive days with sunshine.

Input

The first line of input contains a positive integer, $N$, representing the number of days in the historical data. The following $N$ lines each contain either the character S or the character P, representing a day with sunshine or a day with precipitation, respectively, in chronological order.

Output

Output the non-negative integer, $M$, which is the maximum possible number of consecutive days with sunshine.

Example 1

Input
8
P
S
P
S
S
P
P
S
Output
4

If the data is incorrect for the third day, then there was sunshine from the second day to the fifth day which is four consecutive days with sunshine. This is the maximum possible number of consecutive days with sunshine. That is, no matter which day the data is incorrect for, there were not five (or more) consecutive days of sunshine.

Source
CCC 2025 Junior
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code