Under construction

Still being built. Things may change

Pick Apples

Time limit5sMemory limit1024 MB

Summary
Olga walks between adjacent trees in a two-row orchard from the southwest corner, picking at most K trees. Find the maximum apples she can collect.
Level

Medium7 of 10

Topics
Dynamic programming, Matrix
Solved
No attempts yet

Problem

IOI 2015 was held in Almaty, a name that roughly means 'father of apples'. Olga lives in Almaty and has an apple orchard with two rows of trees. Each row has NN trees. Each tree has a certain number of ripe apples.

Olga starts at the southwest tree (the leftmost tree in the bottom row) and picks all of its apples. Then she walks to one of the nearest trees (north, east, west, or south) and picks its apples.

Given the number of apples on each tree, compute how many apples Olga can pick in total if she has time to pick apples from at most KK trees.

Input

The first line contains the integers NN and KK, separated by a space.

The second line contains NN integers: the number of apples on the trees in the north row, listed from the westernmost tree to the easternmost tree.

The third line contains NN integers: the number of apples on the trees in the south row, listed in the same order.

Output

Your program should print one integer: the number of apples Olga can pick.

Constraints

1≤N≤151 \le N \le 15

1≤K≤151 \le K \le 15

The number of apples on each tree is between 00 and 10001000.

Hint

In the example, Olga can only pick apples from two trees. The starting tree has 6 apples, the tree to the north has 7 apples, and the tree directly to the east has only 4 apples. The most she can pick is therefore 6+7=136 + 7 = 13.

Examples1

  1. Example 1

    Input
    2 2
    7 3
    6 4
    
    Expected output
    13