{"raw_statement":[{"iden":"statement","content":"Your friend Mishka and you attend a calculus lecture. Lecture lasts _n_ minutes. Lecturer tells _a__i_ theorems during the _i_\\-th minute.\n\nMishka 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.\n\nYou 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.\n\nYou 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."},{"iden":"input","content":"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.\n\nThe 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.\n\nThe 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."},{"iden":"output","content":"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."},{"iden":"example","content":"Input\n\n6 3\n1 3 5 2 5 4\n1 1 0 1 0 0\n\nOutput\n\n16"},{"iden":"note","content":"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."}],"translated_statement":[{"iden":"statement","content":"你的朋友 Mishka 和你一起参加微积分讲座。讲座持续 #cf_span[n] 分钟。在第 #cf_span[i] 分钟，讲师讲解了 #cf_span[ai] 个定理。\n\nMishka 对微积分非常感兴趣，但他很难在整个讲座过程中保持清醒。给你一个数组 #cf_span[t] 表示 Mishka 的行为。如果在第 #cf_span[i] 分钟 Mishka 处于睡眠状态，则 #cf_span[ti] 等于 #cf_span[0]；否则等于 #cf_span[1]。当 Mishka 醒着时，他会记下讲师讲解的所有定理——即在第 #cf_span[i] 分钟记下 #cf_span[ai] 个定理；否则他什么也不写。\n\n你知道一种秘密技巧，可以连续保持 Mishka 醒着 #cf_span[k] 分钟。但你只能使用一次。你可以在第 #cf_span[1] 到第 #cf_span[n - k + 1] 分钟的任意一分钟开始使用该技巧。如果你在第 #cf_span[i] 分钟使用它，则 Mishka 将在满足  的所有分钟 #cf_span[j] 中保持清醒，并记下讲师在这些分钟讲解的所有定理。\n\n你的任务是计算：如果你仅使用一次该技巧唤醒 Mishka，他最多能记下多少个定理。\n\n输入的第一行包含两个整数 #cf_span[n] 和 #cf_span[k] (#cf_span[1 ≤ k ≤ n ≤ 105]) —— 讲座的持续时间（分钟）和你能保持 Mishka 醒着的分钟数。\n\n输入的第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ... an] (#cf_span[1 ≤ ai ≤ 104]) —— 讲师在第 #cf_span[i] 分钟讲解的定理数量。\n\n输入的第三行包含 #cf_span[n] 个整数 #cf_span[t1, t2, ... tn] (#cf_span[0 ≤ ti ≤ 1]) —— Mishka 在第 #cf_span[i] 分钟的行为类型。\n\n仅输出一个整数：如果你仅使用一次该技巧唤醒 Mishka，他最多能记下的定理数量。\n\n在样例中，更好的做法是在第三分钟开始使用秘密技巧。此时 Mishka 能记下的定理数量为 #cf_span[16]。"},{"iden":"input","content":"输入的第一行包含两个整数 #cf_span[n] 和 #cf_span[k] (#cf_span[1 ≤ k ≤ n ≤ 105]) —— 讲座的持续时间（分钟）和你能保持 Mishka 醒着的分钟数。第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ... an] (#cf_span[1 ≤ ai ≤ 104]) —— 讲师在第 #cf_span[i] 分钟讲解的定理数量。第三行包含 #cf_span[n] 个整数 #cf_span[t1, t2, ... tn] (#cf_span[0 ≤ ti ≤ 1]) —— Mishka 在第 #cf_span[i] 分钟的行为类型。"},{"iden":"output","content":"仅输出一个整数：如果你仅使用一次该技巧唤醒 Mishka，他最多能记下的定理数量。"},{"iden":"note","content":"在样例中，更好的做法是在第三分钟开始使用秘密技巧。此时 Mishka 能记下的定理数量为 #cf_span[16]。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, k \\in \\mathbb{Z}^+ $ with $ 1 \\leq k \\leq n \\leq 10^5 $.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of positive integers, where $ a_i $ is the number of theorems told in minute $ i $.  \nLet $ T = (t_1, t_2, \\dots, t_n) $ be a binary sequence, where $ t_i = 1 $ if Mishka is awake in minute $ i $, and $ t_i = 0 $ if asleep.\n\n**Constraints**  \n1. $ 1 \\leq a_i \\leq 10^4 $ for all $ i \\in \\{1, \\dots, n\\} $  \n2. $ t_i \\in \\{0, 1\\} $ for all $ i \\in \\{1, \\dots, n\\} $  \n3. $ 1 \\leq k \\leq n $\n\n**Objective**  \nLet $ S_{\\text{base}} = \\sum_{i=1}^n t_i a_i $ be the number of theorems Mishka writes down without intervention.  \n\nFor any starting minute $ i \\in \\{1, \\dots, n - k + 1\\} $, applying the technique makes Mishka awake during minutes $ i, i+1, \\dots, i+k-1 $. The additional theorems gained by applying the technique starting at $ i $ is:  \n$$\n\\Delta_i = \\sum_{j=i}^{i+k-1} (1 - t_j) a_j\n$$  \nThis is the sum of theorems in the interval $ [i, i+k-1] $ that Mishka would have missed while asleep.\n\nThe total theorems written with technique applied at $ i $ is:  \n$$\nS_i = S_{\\text{base}} + \\Delta_i\n$$\n\n**Goal**: Compute  \n$$\n\\max_{i=1}^{n - k + 1} S_i = S_{\\text{base}} + \\max_{i=1}^{n - k + 1} \\sum_{j=i}^{i+k-1} (1 - t_j) a_j\n$$","simple_statement":null,"has_page_source":false}