SPOJ PIGBANK

39. Piggy-bank
http://www.spoj.pl/problems/PIGBANK/

Summary
Given the weight of a piggy bank and the weights and values of individual coins that could be contained in the piggy bank, calculate the minimum sum of the values of the coins.

Input
The first number T is the number of test cases to follow. Each test case begins with a line containing two integers $$1 \le E \le F \le 10000$$ representing the weight if the empty piggy bank and the weight of the full piggy bank respectively. The next line contains a single integer $$1 \le N \le 500$$ representing the number of lines to follow. The following lines contain two integers $$1 \le P \le 50000, 1 \le W \le10000$$ representing the value and the weight of the coin types respectively.

Proposition modeste
Etablir un tableau de dimensions F-E qui indiquera pour chaque valeur du poids, la somme mimimum possible. Y rentrer au début les monnaies disponibles. Remplir ensuite, par valeurs croissantes, ce tableau par une combinaison (si elle existe) des valeurs dèja calculées.

 3 10 110 2 1 1 30 50 10 110 2 1 1 50 30 1 6 2 10 3 20 4 

Output
 The minimum amount of money in the piggy-bank is 60. The minimum amount of money in the piggy-bank is 100. This is impossible. 