#P3718. [AHOI2017初中组] alter

    ID: 2691 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>字符串贪心2017二分安徽枚举,暴力队列

[AHOI2017初中组] alter

Description

There are nn lamps in a row. Some lamps are on, and some are off. Keke wants the lamps to be alternating. He defines the ugliness of a row of lamps as the number of lamps in the longest consecutive segment that are all on or all off. Keke can press switches at most kk times. Each operation toggles the state of one lamp: if it was on, it becomes off; otherwise, it becomes on. Given the current states of the lamps, find the minimal ugliness after the operations.

Input Format

The first line contains two integers n,kn, k.

The second line is a string of length nn consisting of two characters: N and F. Here, N means the lamp is on, and F means the lamp is off.

Output Format

Output the minimal ugliness.

8 1
NNNFFNNN
3

Hint

30%30\% of the testdata: 1kn201\le k \le n\le 20.

50%50\% of the testdata: 1kn3001\le k \le n\le 300.

Another 15%15\% of the testdata: 1kn1051\le k \le n\le 10^5, and the string is all N or all F.

100%100\% of the testdata: 1kn1051\le k \le n\le 10^5.

This problem includes hack testdata.

Translated by ChatGPT 5