J4. Sunny Days
의견: 0
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.
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 the non-negative integer, \(M\), which is the maximum possible number
of consecutive days with sunshine.
| 서브태스크 | 점수 | 설명 |
|---|---|---|
1 | 13점 | There are not many days in the historical data. The data consists of a single block of all |
2 | 26점 | There are not many days in the historical data. The data contains |
3 | 61점 | There are possibly many days in the historical data. — \(N \leq 500\,000\) |
8
P
S
P
S
S
P
P
S4If 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.
평가 및 의견
J4. Sunny Days
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
J4. Sunny Days