Electronics Store

5

1 votes
Dynamic Programming, Algorithms, Medium-Hard, Advanced
Problem

You are in an electronics store. The structure of this store is best described as N+1 blocks (numbered 0 through N) forming a straight line. Block i is adjacent to block i+1 for all 0i<N. For every i1, block i contains Qi copies of product i, each of which is worth Pi HackerCoins. Block 0 does not contain any products.

The store is holding a special event, offering its 3,141,592nd visitor a very special chance to take home whatever he or she can grab in a given amount of time, for free. And the winner has just been announced. Yes — it is you!

The rules are simple. You start in block 0, which also contains a stationary cart. You have t seconds to move around the store, picking some products and getting them to the cart. After that time you win whatever is in the cart. However, at any moment of time, it is forbidden to hold more than one copy of the same product. Also, you can drop the taken products only in the cart.

Thanks to your incredible strength, it takes you only exactly 1 second to move to an adjacent block, regardless of how many products you are carrying. Picking up a copy of product i takes you Wi seconds, while placing anything in the cart takes no time.

The store has yet to decide how much time to give to you. For all integers t such that 1tT, determine the maximum possible total worth of the products you can win, in HackerCoins.
 

Input

The first line contains two space-separated integers N and T — the number of blocks (not counting block 0) and the limitation for the allowed time, respectively.

The second line contains N space-separated integers: Q1, Q2, , QN — the number of copies available of each product.

The third line contains N space-separated integers: P1, P2, , PN — the worth (value) of each product, in HackerCoins.

The fourth line contains N space-separated integers: W1, W2, , WN — the time needed to pick up a copy of each product, in seconds.

Output

Print one line containing T space-separated integers, the t-th of which is the maximum total worth of the products you could obtain were you given t seconds, in HackerCoins. Remember that you win only the products placed in the cart.

Constraints

1N300

1T5000

1Qi1000

1Pi100000

1Wi1000

Note that the expected output feature for custom input is disabled for this contest. 

Time Limit: 2.5
Memory Limit: 256
Source Limit:
Explanation

If t=5, an optimal strategy is to head to block 2 (2 seconds), pick product 2 up (1 second), then return to block 0 (2 seconds) and place down product 2 in the cart. This takes 2+1+2=5 seconds, which is just enough. The total worth of products won is 78 HackerCoins.

If t=8, an optimal strategy is to head to block 2 and pick one copy of products 1 and 2 along the way up before returning to block 0 and placing the held products in the cart. This strategy takes 7 seconds. Notice that you do not need to use all given time. The total worth of products won is 63+78=141 HackerCoins.

If t=10, an optimal strategy is to follow the strategy when t=5 twice. As a result, the total worth of products won is 78+78=156 HackerCoins.

Editor Image

?