#abc229g. G - Longest Y
G - Longest Y
Score : points
问题描述
给定一个由 Y
和 .
组成的字符串 。
你可以在 到 次(包含)之间对 执行以下操作:
- 交换 中的两个相邻字符。
在执行操作后, 中连续 Y
s 的最大可能数量是多少?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is a string consisting of Y
and .
.
You can do the following operation on between and times (inclusive).
- Swap two adjacent characters in .
What is the maximum possible number of consecutive Y
s in after the operations?
Constraints
- Each character of is
Y
or.
. - is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
YY...Y.Y.Y.
2
Sample Output 1
3
After swapping the -th, -th characters, and -th, -th characters, we have YY....YYY..
, which has three consecutive Y
s at -th through -th positions.
We cannot have four or more consecutive Y
s, so the answer is .
Sample Input 2
YYYY....YYY
3
Sample Output 2
4
update @ 2024/3/10 10:01:53