A11722 | Lecture Sleep
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Your friend Mishka and you attend a calculus lecture. Lecture lasts $n$ minutes. Lecturer tells $a_{i}$ theorems during the $i$ -th minute.
Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array $t$ of Mishka's behavior. If Mishka is asleep during the $i$ -th minute of the lecture then $t_{i}$ will be equal to $0$ , otherwise it will be equal to $1$ . When Mishka is awake he writes down all the theorems he is being told — $a_{i}$ during the $i$ -th minute. Otherwise he writes nothing.
You know some secret technique to keep Mishka awake for $k$ minutes straight. However you can use it only once. You can start using it at the beginning of any minute between $1$ and $n-k+1$ . If you use it on some minute $i$ then Mishka will be awake during minutes $j$ such that  and will write down all the theorems lecturer tells.
You task is to calculate the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.
Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array $t$ of Mishka's behavior. If Mishka is asleep during the $i$ -th minute of the lecture then $t_{i}$ will be equal to $0$ , otherwise it will be equal to $1$ . When Mishka is awake he writes down all the theorems he is being told — $a_{i}$ during the $i$ -th minute. Otherwise he writes nothing.
You know some secret technique to keep Mishka awake for $k$ minutes straight. However you can use it only once. You can start using it at the beginning of any minute between $1$ and $n-k+1$ . If you use it on some minute $i$ then Mishka will be awake during minutes $j$ such that  and will write down all the theorems lecturer tells.
You task is to calculate the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.
输入格式
The first line of the input contains two integer numbers $n$ and $k$ ( $1<=k<=n<=10^{5}$ ) — the duration of the lecture in minutes and the number of minutes you can keep Mishka awake.
The second line of the input contains $n$ integer numbers $a_{1},a_{2},...\ a_{n}$ ( $1<=a_{i}<=10^{4}$ ) — the number of theorems lecturer tells during the $i$ -th minute.
The third line of the input contains $n$ integer numbers $t_{1},t_{2},...\ t_{n}$ ( $0<=t_{i}<=1$ ) — type of Mishka's behavior at the $i$ -th minute of the lecture.
The second line of the input contains $n$ integer numbers $a_{1},a_{2},...\ a_{n}$ ( $1<=a_{i}<=10^{4}$ ) — the number of theorems lecturer tells during the $i$ -th minute.
The third line of the input contains $n$ integer numbers $t_{1},t_{2},...\ t_{n}$ ( $0<=t_{i}<=1$ ) — type of Mishka's behavior at the $i$ -th minute of the lecture.
输出格式
Print only one integer — the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.
输入输出样例
输入 #1
6 3 1 3 5 2 5 4 1 1 0 1 0 0
输出 #1
16
In the sample case the better way is to use the secret technique at the beginning of the third minute. Then the number of theorems Mishka will be able to write down will be equal to $16$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted