AT_abc479_b.Longest Rainy Streak

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Takahashi recorded the weather for NN consecutive days, recording each day as "sunny" or "rainy".
His record is given as a string SS of length NN in the following format.

  • The ii-th character ( 1≤i≤N1 \le i \le N ) of SS represents the weather on the ii-th day from the start of the record.
    • If the ii-th character of SS is S, the record for that day was "sunny".
    • If the ii-th character of SS is R, the record for that day was "rainy".

Find the maximum number of consecutive days for which Takahashi recorded "rainy".
If Takahashi never recorded "rainy", the answer is 00.

高桥记录了连续 NN 天的天气,每天记录为“晴天”或“雨天”。
该记录以长度为 NN 的字符串 SS 给出,格式如下:

  • 字符串 SS 的第 ii 个字符(1≤i≤N1 \le i \le N)表示从记录开始起第 ii 天的天气。
    • 若 SS 的第 ii 个字符为 S,则当天记录为“晴天”;
    • 若 SS 的第 ii 个字符为 R,则当天记录为“雨天”。

求高桥记录中“雨天”连续出现的最大天数。
若高桥从未记录过“雨天”,则答案为 00。

输入格式

The input is given from Standard Input in the following format:

NN
SS

输入从标准输入中按以下格式给出:

NN
SS

输出格式

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,64,5,6, and there is no longer consecutive run of "rainy", so the maximum number of consecutive days with "rainy" recorded is 33.

Sample 2 Explanation:
Takahashi never recorded "rainy". In this case, the answer is 00.

Constraints

  • NN is an integer satisfying 1≤N≤1001 \le N \le 100.
  • SS is a string of length NN consisting of S and R.

样例 1 解释:
从第一天开始,高桥记录的天气依次为:雨、雨、晴、雨、雨、雨、晴。
其中,“雨”在第 4,5,64,5,6 天连续出现,且不存在更长的连续“雨”记录,因此连续“雨”天数的最大值为 33。

样例 2 解释:
高桥从未记录过“雨”。此时答案为 00。

约束条件

  • NN 是满足 1≤N≤1001 \le N \le 100 的整数。
  • SS 是一个长度为 NN 的字符串,仅由字符 S 和 R 组成。

输入解题思路,AI测评打分。不知道怎么写?

首页