A13095 | New Year and Handle Change
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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]$ 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 $l$ is fixed for all changes.
Because it is not allowed to change codeforces handle too often, Mishka can perform at most $k$ such operations. What is the minimum value of $min(lower, upper)$ (where $lower$ is the number of lowercase letters, and $upper$ is the number of uppercase letters) can be obtained after optimal sequence of changes?
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]$ 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 $l$ is fixed for all changes.
Because it is not allowed to change codeforces handle too often, Mishka can perform at most $k$ such operations. What is the minimum value of $min(lower, upper)$ (where $lower$ is the number of lowercase letters, and $upper$ is the number of uppercase letters) can be obtained after optimal sequence of changes?
输入格式
The first line of the input contains three integers $n, k$ and $l$ ( $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 $s$ , consisting of $n$ lowercase and uppercase Latin letters — Mishka's handle.
The second line of the input contains one string $s$ , consisting of $n$ lowercase and uppercase Latin letters — Mishka's handle.
输出格式
Print one integer — the minimum value of $min(lower, upper)$ after that Mishka change his handle at most $k$ times in a way described in the problem statement.
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted