# P3423 [POI2005]BAN-Bank Notes

• 93通过
• 371提交
• 题目提供者 洛谷
• 评测方式 云端评测
• 标签 动态规划,动规,dp POI 2005 Special Judge 高性能
• 难度 省选/NOI-
• 时空限制 1000ms / 64MB
• 提示：收藏到任务计划后，可在首页查看。

## 题目描述

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,\cdots,b_n$. The BBB have concluded that the cash dispensers are to pay every sum in the smallest possible total number of notes.

TaskWrite 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.

Byteotian Bit Bank (BBB) 拥有一套先进的货币系统,这个系统一共有n种面值的硬币,面值分别为b1, b2,…, bn. 但是每种硬币有数量限制,现在我们想要凑出面值k求最少要用多少个硬币.

## 输入输出格式

输入格式：

In the first line of the standard input the number of denominations is written $n$, $1\le n\le 200$. The second line contains $n$ integers $b_1,b_2,\cdots,b_n$, $1\le b_1<b_2<\cdots<b_n\le 20\ 000$, separated by single spaces. The third line contains $n$ integers $c_1,c_2,\cdots,c_n$, $1\le c_i\le 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\le k\le 20\ 000$ . For the test data, you are free to assume that the sum $k$ can be paid off in the available banknotes.

输出格式：

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.

## 输入输出样例

输入样例#1： 复制
3
2 3 5
2 2 1
10
输出样例#1： 复制
3
1 1 1
提示
标程仅供做题后或实在无思路时参考。
请自觉、自律地使用该功能并请对自己的学习负责。
如果发现恶意抄袭标程，将按照I类违反进行处理。