#P5997. [PA 2014] Pakowanie
[PA 2014] Pakowanie
Description
You have items and bags. Each item has a weight and cannot be split; each bag has its own capacity. To pack all items into the bags, what is the minimum number of bags needed?
Input Format
The first line contains two integers , representing the number of items and the number of bags.
The second line contains integers , where is the weight of the -th item.
The third line contains integers , where is the capacity of the -th bag.
Output Format
If it is possible to pack all items, output one integer representing the minimum number of bags used.
If it is not possible to pack all items, output NIE.
4 3
4 2 10 3
11 18 9
2
Hint
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号