Globalization has reached even the old and honest trade of burglary. Breaking in somewhere, grabbing whatever you can carry and running off is no longer enough. To stay competitive you have to optimize your profit.
The new rules are:
- rob only enormous stores, where the supply of every item type is effectively unlimited;
- carry an enormous knapsack;
- leave no empty space in the knapsack.
Those rules are hard to follow, so you write a program that decides whether a store is worth robbing.
The store sells n types of items, and one item of type i takes exactly gi units of space. You may take any number of items of each type, including none. Decide whether some choice of items fills a knapsack of size k exactly, with no space left over.