CF961B.Lecture Sleep

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Your friend Mishka and you attend a calculus lecture. Lecture lasts nn minutes. Lecturer tells aia_{i} theorems during the ii -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 tt of Mishka's behavior. If Mishka is asleep during the ii -th minute of the lecture then tit_{i} will be equal to 00 , otherwise it will be equal to 11 . When Mishka is awake he writes down all the theorems he is being told — aia_{i} during the ii -th minute. Otherwise he writes nothing.

You know some secret technique to keep Mishka awake for kk minutes straight. However you can use it only once. You can start using it at the beginning of any minute between 11 and nk+1n-k+1 . If you use it on some minute ii then Mishka will be awake during minutes jj 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 nn and kk ( 1<=k<=n<=1051<=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 nn integer numbers a1,a2,... ana_{1},a_{2},...\ a_{n} ( 1<=ai<=1041<=a_{i}<=10^{4} ) — the number of theorems lecturer tells during the ii -th minute.

The third line of the input contains nn integer numbers t1,t2,... tnt_{1},t_{2},...\ t_{n} ( 0<=ti<=10<=t_{i}<=1 ) — type of Mishka's behavior at the ii -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 1616 .

首页