CF961B.Lecture Sleep

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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.

你的朋友米什卡和你一起参加一节微积分课。这节课持续 nn 分钟。在第 ii 分钟,讲师讲授 aia_i 个定理。

米什卡对微积分非常感兴趣,但整节课保持清醒却十分困难。你被给定一个数组 tt,描述米什卡的听课状态:若米什卡在第 ii 分钟处于睡眠状态,则 ti=0t_i = 0;否则 ti=1t_i = 1。当米什卡清醒时,他会记下该分钟讲师所讲授的所有定理——即第 ii 分钟的 aia_i 个定理;当他睡着时,则一个字也不记。

你掌握一种秘密技巧,可让米什卡连续保持清醒 kk 分钟。但该技巧只能使用一次。你可以在第 11 至第 n−k+1n - k + 1 分钟之间的任意一分钟(含端点)开始使用该技巧。若你在第 ii 分钟启动该技巧,则米什卡将在所有满足 的分钟 jj 内保持清醒,并记下讲师在这些分钟内所讲授的所有定理。

你的任务是:计算在仅使用一次该技巧唤醒米什卡的前提下,他最多能记下多少个定理。

输入格式

The first line of the input contains two integer numbers n and k (1 ≤ k ≤ n ≤ 105) — 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 ≤ 104) — 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.

输入的第一行包含两个整数 nn 和 kk(1 ≤ k ≤ n ≤ 1051 ≤ k ≤ n ≤ 10^5)—— 分别表示讲座的总时长(单位:分钟)以及你能让 Mishka 保持清醒的分钟数。

输入的第二行包含 nn 个整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n(1 ≤ ai ≤ 1041 ≤ a_i ≤ 10^4)—— 表示讲师在第 ii 分钟所讲定理的数量。

输入的第三行包含 nn 个整数 t1, t2, …, tnt_1,\,t_2,\,\dots,\,t_n(0 ≤ ti ≤ 10 ≤ t_i ≤ 1)—— 表示 Mishka 在讲座第 ii 分钟的行为类型。

输出格式

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.

仅输出一个整数——即如果你仅使用一次你的技巧来唤醒 Mishka,他最多能记下的定理数量。

输入输出样例

  • 输入#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.

在样例中,更好的方法是在第三分钟开始时使用秘密技巧。此时,Mishka 能够记下的定理数量将等于 1616。

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

首页