#P3423. [POI 2005] BAN-Bank Notes

[POI 2005] BAN-Bank Notes

Description

Byteotian Bit Bank(BBB) has an advanced currency system. There are nn coin denominations with values b1,b2,,bnb_1, b_2, \cdots, b_n. However, each coin has a limited quantity. Now we want to make a total value of kk. Find the minimum number of coins needed. It is guaranteed that kk can be formed.

Input Format

The first line contains an integer nn.

The second line contains nn integers bib_i, the denominations of these nn types of coins.

The third line contains nn integers cic_i, the quantity of each of these nn types of coins.

The fourth line contains an integer kk.

Output Format

The first line contains an integer, the minimum number of coins required.

The second line contains nn integers, where the ii-th number is how many coins of type ii are used.

If there are multiple solutions, output any one of them.

3
2 3 5
2 2 1
10
3
1 1 1

Hint

For 100%100\% of the testdata, 1n2001 \le n \le 200, 1b1<b2<<bn2×1041 \le b_1 < b_2 < \cdots < b_n \le 2 \times 10^4, 1ci2×1041 \le c_i \le 2 \times 10^4, 1k2×1041 \le k \le 2 \times 10^4.

Translated by ChatGPT 5