A9292 | Inna and Candy Boxes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The first line of the input contains three integers $n$ , $k$ and $w$ $(1<=k<=min(n,10),1<=n,w<=10^{5})$ . The second line contains $n$ characters. If the $i$ -th box contains a candy, the $i$ -th character of the line equals 1, otherwise it equals 0.
Each of the following $w$ lines contains two integers $l_{i}$ and $r_{i}$ $(1<=l_{i}<=r_{i}<=n)$ — the description of the $i$ -th question. It is guaranteed that $r_{i}-l_{i}+1$ is divisible by $k$ .
Each of the following $w$ lines contains two integers $l_{i}$ and $r_{i}$ $(1<=l_{i}<=r_{i}<=n)$ — the description of the $i$ -th question. It is guaranteed that $r_{i}-l_{i}+1$ is divisible by $k$ .
输入格式
For each question, print a single number on a single line — the minimum number of operations Dima needs to make the answer to the question positive.
输出格式
For the first question, you need to take a candy from the first box to make the answer positive. So the answer is 1.
For the second question, you need to take a candy from the first box, take a candy from the fifth box and put a candy to the sixth box. The answer is 3.
For the third question, you need to take a candy from the fifth box and put it to the sixth box. The answer is 2.
For the second question, you need to take a candy from the first box, take a candy from the fifth box and put a candy to the sixth box. The answer is 3.
For the third question, you need to take a candy from the fifth box and put it to the sixth box. The answer is 2.
输入输出样例
输入 #1
10 3 3 1010100011 1 3 1 6 4 9
输出 #1
1 3 2
For the first question, you need to take a candy from the first box to make the answer positive. So the answer is 1.
For the second question, you need to take a candy from the first box, take a candy from the fifth box and put a candy to the sixth box. The answer is 3.
For the third question, you need to take a candy from the fifth box and put it to the sixth box. The answer is 2.
For the second question, you need to take a candy from the first box, take a candy from the fifth box and put a candy to the sixth box. The answer is 3.
For the third question, you need to take a candy from the fifth box and put it to the sixth box. The answer is 2.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted