NECプログラミングコンテスト2021(AtCoder Beginner Contest 229)
翻译中…
Problem Statement
翻译中…
Given is a string $S$ consisting of Y and ..
翻译中…
You can do the following operation on $S$ between $0$ and $K$ times (inclusive).
翻译中…
- Swap two adjacent characters in
$S$.
翻译中…
What is the maximum possible number of consecutive Ys in $S$ after the operations?
翻译中…
Constraints
翻译中…
$2 \leq |S| \leq 2 \times 10^5$- Each character of
$S$isYor.. $0 \leq K \leq 10^{12}$$K$is an integer.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
S
K
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
YY...Y.Y.Y.
2
Output #1
3
After swapping the $6$-th, $7$-th characters, and $9$-th, $10$-th characters, we have `YY....YYY..`, which has three consecutive `Y`s at $7$-th through $9$-th positions.
We cannot have four or more consecutive `Y`s, so the answer is $3$.
Input #2
YYYY....YYY
3
Output #2
4
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。