Under construction

Still being built. Things may change

Yukhoe Bibimbap

Interview

Time limit1sMemory limit512 MB

Summary
Bosun must visit all N stations in some order where consecutive glare products stay at most K, maximizing the sum of A of the previous station times B of the next.
Level

Medium4 of 10

Topics
Dynamic programming, Bit manipulation
Solved
No attempts yet

Problem

Bosun went to Jinju for a trip and was so hungry that he went to Daean-dong in Jinju to eat yukhoe bibimbap. Lucky him, a tasting event for yukhoe bibimbap was underway. Bosun, a big eater and a gourmet, wants to eat every bowl to get the most umami possible. But the staff at the tasting stations have started to glare at him, even though he is shameless. So he decided to study the information about each station and eat strategically.

There are NN tasting stations in total. Each station has one bowl of yukhoe bibimbap and one staff member. The sweetness and saltiness of the bibimbap, and how much the staff member glares, can be expressed as numbers. Bosun can pick any station that still has bibimbap left, and every time he visits a station he must eat all the bibimbap there.

Let AiA_i and BiB_i be the sweetness and saltiness of the bibimbap at the station Bosun visits ii-th. The total umami he feels is: ∑i=2NAi−1×Bi\sum_{i=2}^{N} A_{i-1} \times B_i

Bosun receives no glare at the first station, but from the second station on, he is glared at. Let CiC_i be the glare level of the staff at the ii-th station visited. Then the glare Bosun receives at the ii-th station (i≥2i \ge 2) is Ci−1×CiC_{i-1} \times C_i. However, Bosun has KK units of shamelessness, so if the glare is KK or less, he ignores it and eats the bibimbap there. If the glare exceeds KK, he cannot eat the bibimbap there and must stop.

Considering these conditions, find the maximum total umami Bosun can feel when he eats all NN bowls.

Input

The first line contains the number of tasting stations NN and Bosun's shamelessness KK, separated by a space. (2≤N≤102 \le N \le 10, 1≤K≤1001 \le K \le 100)

The second line contains the sweetness A1,…,ANA_1, \dots, A_N of the bibimbap at each station, separated by spaces. (1≤Ai≤101 \le A_i \le 10)

The third line contains the saltiness B1,…,BNB_1, \dots, B_N of the bibimbap at each station, separated by spaces. (1≤Bi≤101 \le B_i \le 10)

The fourth line contains the glare level C1,…,CNC_1, \dots, C_N of the staff at each station, separated by spaces. (1≤Ci≤101 \le C_i \le 10)

All numbers in the input are integers.

Output

On the first line, print the maximum total umami Bosun can feel when he eats all NN bowls. If he cannot eat all NN bowls of bibimbap, print -1.

Hint

Python 3 users are recommended to submit with PyPy3.

Examples2

  1. Example 1

    Input
    3 6
    10 5 2
    2 10 5
    2 3 1
    
    Expected output
    125
    
  2. Example 2

    Input
    3 8
    1 1 1
    2 2 2
    3 3 3
    
    Expected output
    -1