View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 1G

Author:
Problem type

Terradog is purchasing gifts for his friend Stacy! In front of him are stores which he can choose to purchase gifts from. Each store sells exactly type of item, and he can purchase a maximum of item per store. He can purchase from as many stores as he wants. Terradog knows that the item at the -th store has a quality of . He also knows that the value of the item at the -th store is .

In order for the gift to be as perfect as possible, Terradog wants all items he purchases to be of quality . Luckily, he has a special move he can use up to times! Terradog has an array of integers, each with value . On any move, he can increase the quality of an item purchased at the -th store by any from his array.

Terradog would like to give Stacy a gift with the maximum possible total value, whilst also ensuring all purchased items are of quality . Can you output what the maximum possible total value of gifts he can obtain is?

#### Input Specifications

The first line will contain four space-separated integers, , , , and , the number of stores Terradog can purchase from, the length of Terradog's array, the number of times Terradog can use his move, and the quality Terradog wants to make all his gifts, respectively.

The next line will contain space-separated integers, , where represents the quality of the item purchased at the -th store.

The next line will contain space separated integers, , where represents the value of the item purchased at the -th store.

The next line will contain space-separated integers, , where is a value in Terradog's array.

#### Output Specifications

Output a single integer, the maximum possible total value of gifts Terradog can obtain.

#### Sample Input

4 3 4 14
1 14 4 2
80 1 2 4
1 4 6

#### Sample Output

81

#### Explanation

Terradog can first purchase a gift from shop , with a quality of and a value of . He can then use his move times on shop , increasing the quality by , , and , for a total quality of . He can then purchase the gift with a value of . In total, the combined value will be .