Maximizing happiness

0

0 votes
Easy
Problem

Baba has taken up a course on the Science of Happiness and Well Being. Being a regular to the classes, he has been deeply influenced by the lectures given by the different professors. One of the points which resonated with him the most was the co-relation between Sports and Happiness. Baba narrows his interests down to 2 types of sports on any day, A or B. The happiness of playing A on an ith day is given by A[i], and happiness of playing game B on ith day is given by B[i]. Obviously, he wants to maximize his total happiness. However, he does not want to play the same sport for more than k consecutive days , lest he might wear himself out and lose interest in the sport. Find the maximum sum of happiness he can get and ace his project on the Science of Happiness and Well Being.

Input

The first line of the input contains two integers n and k.
next line contains n space separated integers, where the i th value is that of A[i].
next line contains n space separated integers, where the i th value is that of B[i].

Output

Print a single line containing a single integer denoting the Maximum sum of happiness possible.

Constraints

1 ≤ n, k ≤ 100000
1 ≤ A[i],B[i] ≤ 109

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?