{"trustable":false,"sections":[{"title":"题意","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"ch-CH\"\u003e\n \u003cp\u003e已知整个交易系统有N (1 ≤ N ≤ 100)种不同的货币,分别价值V1,V2,V3.......VN(1 ≤ Vi ≤ 120),FJ分别有C1,C2,C3.....CN(0 ≤ Ci ≤10,000)张相应价值货币。FJ只能用仅有的货币去买价值T(1 ≤T≤10,000)分的东西,而老板有无数的货币可以找给他。求FJ给老板的货币数+老板找给FJ的货币数的最小值。\u003c/p\u003e\n \u003c/p\u003e\n \u003c/div\u003e"}},{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n \u003cp\u003eFarmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the number of coins he uses to pay plus the number of coins he receives in change is minimized. Help him to determine what this minimum number is.\u003c/p\u003e\n \u003cp\u003eFJ wants to buy \u003ci\u003eT\u003c/i\u003e (1 ≤ \u003ci\u003eT\u003c/i\u003e ≤ 10,000) cents of supplies. The currency system has \u003ci\u003eN\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 100) different coins, with values \u003ci\u003eV\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003eV\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, ..., \u003ci\u003eV\u003csub\u003eN\u003c/sub\u003e\u003c/i\u003e (1 ≤ \u003ci\u003eV\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ 120). Farmer John is carrying \u003ci\u003eC\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e coins of value \u003ci\u003eV\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003eC\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e coins of value \u003ci\u003eV\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, ...., and \u003ci\u003eC\u003csub\u003eN\u003c/sub\u003e\u003c/i\u003e coins of value \u003ci\u003eV\u003csub\u003eN\u003c/sub\u003e\u003c/i\u003e (0 ≤ \u003ci\u003eC\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ 10,000). The shopkeeper has an unlimited supply of all the coins, and always makes change in the most efficient manner (although Farmer John must be sure to pay in a way that makes it possible to make the correct change).\u003c/p\u003e\n \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Line 1: Two space-separated integers: \n \u003ci\u003eN\u003c/i\u003e and \n \u003ci\u003eT\u003c/i\u003e. \n \u003cbr\u003eLine 2: N space-separated integers, respectively \n \u003ci\u003eV\u003c/i\u003e\n \u003csub\u003e1\u003c/sub\u003e, \n \u003ci\u003eV\u003c/i\u003e\n \u003csub\u003e2\u003c/sub\u003e, ..., \n \u003ci\u003eV\u003csub\u003eN\u003c/sub\u003e\u003c/i\u003e coins (\n \u003ci\u003eV\u003c/i\u003e\n \u003csub\u003e1\u003c/sub\u003e, ...\n \u003ci\u003eV\u003csub\u003eN\u003c/sub\u003e\u003c/i\u003e) \n \u003cbr\u003eLine 3: N space-separated integers, respectively \n \u003ci\u003eC\u003c/i\u003e\n \u003csub\u003e1\u003c/sub\u003e, \n \u003ci\u003eC\u003c/i\u003e\n \u003csub\u003e2\u003c/sub\u003e, ..., \n \u003ci\u003eC\u003csub\u003eN\u003c/sub\u003e\u003c/i\u003e\n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Line 1: A line containing a single integer, the minimum number of coins involved in a payment and change-making. If it is impossible for Farmer John to pay and receive exact change, output -1.\n \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e3 70\n5 25 50\n5 2 1\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e3\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Farmer John pays 75 cents using a 50 cents and a 25 cents coin, and receives a 5 cents coin in change, for a total of 3 coins used in the transaction.\n \u003c/div\u003e"}}]}