QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#11862. Bank Notes

Statistics

The Byteotian Bit Bank (BBB) has the largest network of cash dispensers in the whole Byteotia. The BBB have decided to improve their dispensers and have asked you for help. The legal tender in Byteotia are bank notes of denominations $b_1,b_2,…,b_n$. The BBB have concluded that the cash dispensers are to pay every sum in the smallest possible total number of notes.

Write a programme that:

  • reads from the standard input the description of the dispenser's notes stock and the sum to be paid off,
  • determines the minimal total number of bank notes sufficient to pay the desired sum off, and finds some way of paying it off as well (using the determined minimal number of notes, of course)
  • writes the result to the standard output.

Input

In the first line of the standard input the number of denominations is written $n$, $1 ≤ n ≤ 200$. The second line contains $n$ integers $b_1,b_2,…,b_n$, $1 ≤ b_1 < b_2 < … < b_n ≤ 20\,000$, separated by single spaces. The third line contains $n$ integers $c_1,c_2,…,c_n$, $1 ≤ c_i ≤ 20\,000$, also separated by single spaces; $c_i$ is the number of banknotes of denomination $b_i$ left in the cash dispenser. In the last, fourth line of input there is one integer $k$ - the sum to be paid off, $1 ≤ k ≤ 20\,000$. For the test data, you are free to assume that the sum $k$ can be paid off in the available banknotes.

Output

The first line of the standard output should contain one integer denoting the minimal total number of bank notes sufficient to pay the sum off $k$. The second line should contain $n$ integers, separated by single spaces, denoting the numbers of notes of subsequent denominations used to pay off the sum $k$. If there are many solutions your programme should write any of them.

Example

Input

3
2 3 5
2 2 1
10

Output

3
1 1 1
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.