CF1279F.New Year and Handle Change

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

New Year is getting near. So it's time to change handles on codeforces. Mishka wants to change his handle but in such a way that people would not forget who he is.

To make it work, he only allowed to change letters case. More formally, during one handle change he can choose any segment of his handle [i;i+l−1][i; i + l - 1] and apply tolower or toupper to all letters of his handle on this segment (more fomally, replace all uppercase letters with corresponding lowercase or vice versa). The length ll is fixed for all changes.

Because it is not allowed to change codeforces handle too often, Mishka can perform at most kk such operations. What is the minimum value of min(lower,upper)min(lower, upper) (where lowerlower is the number of lowercase letters, and upperupper is the number of uppercase letters) can be obtained after optimal sequence of changes?

新年临近,是时候在 Codeforces 上更换昵称了。Mishka 想要更改自己的昵称,但希望人们仍能记住他是谁。

为实现这一目标,他只允许更改字母的大小写。更准确地说,在一次昵称修改操作中,他可以选择昵称的任意一个子段 [i;i+l−1][i; i + l - 1],并对该子段内所有字母统一执行 tolower 或 toupper 操作(即:将所有大写字母替换为对应的小写字母,或反之)。每次操作所选子段的长度 ll 是固定的。

由于 Codeforces 不允许过于频繁地更改昵称,Mishka 最多只能执行 kk 次这样的操作。在经过最优的操作序列后,min(lower,upper)min(lower, upper)(其中 lowerlower 表示小写字母的数量,upperupper 表示大写字母的数量)所能达到的最小值是多少?

输入格式

The first line of the input contains three integers n,kn, k and ll (1≤n,k,l≤106,l≤n)1 \le n, k, l \le 10^6, l \le n) — the length of Mishka's handle, the number of changes and the length of the segment.

The second line of the input contains one string ss, consisting of nn lowercase and uppercase Latin letters — Mishka's handle.

输入的第一行包含三个整数 n,kn, k 和 ll(1≤n,k,l≤106,l≤n1 \le n, k, l \le 10^6, l \le n)——分别表示 Mishka 用户名的长度、修改次数以及区间长度。

输入的第二行包含一个字符串 ss,由 nn 个大小写拉丁字母组成——即 Mishka 的用户名。

输出格式

Print one integer — the minimum value of min(lower,upper)min(lower, upper) after that Mishka change his handle at most kk times in a way described in the problem statement.

输出一个整数——在 Mishka 按照题目描述的方式最多更改用户名 kk 次后,min(lower,upper)min(lower, upper) 的最小可能值。

输入输出样例

  • 输入#1

    7 1 4
    PikMike

    输出#1

    0
  • 输入#2

    15 2 2
    AaAaAAaaAAAAaaA

    输出#2

    2
  • 输入#3

    14 2 6
    aBcdEFGHIJklMn

    输出#3

    0
  • 输入#4

    9 2 2
    aAaAAAaaA

    输出#4

    1

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

首页