欧姆龙编程竞赛 2026(第 479 场 AtCoder Beginner Contest)
最长连续雨天AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)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.
高桥记录了连续 $N$ 天的天气,每天记录为“晴天”或“雨天”。
他的记录以长度为 $N$ 的字符串 $S$ 表示,格式如下。AI (CI翻译)
- The
$i$-th character ($1 \le i \le N$) of$S$represents the weather on the$i$-th day from the start of the record. - If the
$i$-th character of$S$isS, the record for that day was "sunny".- If the
$i$-th character of$S$isR, the record for that day was "rainy".
- If the
$S$的第$i$个字符($1 \le i \le N$)表示从记录开始算起第$i$天的天气。- 如果
$S$的第$i$个字符是S,则当天是“晴天”。- 如果
$S$的第$i$个字符是R,则当天是“雨天”。
- 如果
Find the maximum number of consecutive days for which Takahashi recorded "rainy".
If Takahashi never recorded "rainy", the answer is $0$.
请找出高桥连续记录为“雨天”的天数的最大值。
如果高桥从未记录过“雨天”,答案为 $0$。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$N$is an integer satisfying$1 \le N \le 100$.$S$is a string of length$N$consisting ofSandR.
$N$是满足$1 \le N \le 100$的整数。$S$是一个长度为$N$、由S和R组成的字符串。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N
S
N
SAI (CI翻译)
Output
输出格式
AI (CI翻译)Output the answer.
输出答案。AI (CI翻译)
样例
Input #1
7
RRSRRRS
Output #1
3
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$.
Input #2
10
SSSSSSSSSS
Output #2
0
Takahashi never recorded "rainy". In this case, the answer is $0$.
Input #3
20
RRRSRRRRSSRRRRSRSRRR
Output #3
4
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。