AT_abc479_b.Longest Rainy Streak
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Takahashi recorded the weather for N consecutive days, recording each day as "sunny" or "rainy".
His record is given as a string S of length N in the following format.
- The i-th character ( 1≤i≤N ) of S represents the weather on the i-th day from the start of the record.
- If the i-th character of S is
S, the record for that day was "sunny". - If the i-th character of S is
R, the record for that day was "rainy".
- If the i-th character of S is
Find the maximum number of consecutive days for which Takahashi recorded "rainy".
If Takahashi never recorded "rainy", the answer is 0.
高桥记录了连续 N 天的天气,每天记录为“晴天”或“雨天”。
该记录以长度为 N 的字符串 S 给出,格式如下:
- 字符串 S 的第 i 个字符(1≤i≤N)表示从记录开始起第 i 天的天气。
- 若 S 的第 i 个字符为
S,则当天记录为“晴天”; - 若 S 的第 i 个字符为
R,则当天记录为“雨天”。
- 若 S 的第 i 个字符为
求高桥记录中“雨天”连续出现的最大天数。
若高桥从未记录过“雨天”,则答案为 0。
输入格式
The input is given from Standard Input in the following format:
N
S
输入从标准输入中按以下格式给出:
N
S
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
7 RRSRRRS
输出#1
3
输入#2
10 SSSSSSSSSS
输出#2
0
输入#3
20 RRRSRRRRSSRRRRSRSRRR
输出#3
4
说明/提示
Sample 1 Explanation:
Starting from the first day, Takahashi recorded rainy, rainy, sunny, rainy, rainy, rainy, sunny.
"Rainy" was recorded consecutively on days 4,5,6, and there is no longer consecutive run of "rainy", so the maximum number of consecutive days with "rainy" recorded is 3.
Sample 2 Explanation:
Takahashi never recorded "rainy". In this case, the answer is 0.
Constraints
- N is an integer satisfying 1≤N≤100.
- S is a string of length N consisting of
SandR.
样例 1 解释:
从第一天开始,高桥记录的天气依次为:雨、雨、晴、雨、雨、雨、晴。
其中,“雨”在第 4,5,6 天连续出现,且不存在更长的连续“雨”记录,因此连续“雨”天数的最大值为 3。
样例 2 解释:
高桥从未记录过“雨”。此时答案为 0。
约束条件
- N 是满足 1≤N≤100 的整数。
- S 是一个长度为 N 的字符串,仅由字符
S和R组成。
输入解题思路,AI测评打分。不知道怎么写?