|
||||||||||
The trouble of XiaoqianTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3356 Accepted Submission(s): 1160 Problem Description In the country of ALPC , Xiaoqian is a very famous mathematician. She is immersed in calculate, and she want to use the minimum number of coins in every shopping. (The numbers of the shopping include the coins she gave the store and the store backed to her.) And now , Xiaoqian wants to buy T (1 ¡Ü T ¡Ü 10,000) cents of supplies. The currency system has N (1 ¡Ü N ¡Ü 100) different coins, with values V1, V2, ..., VN (1 ¡Ü Vi ¡Ü 120). Xiaoqian is carrying C1 coins of value V1, C2 coins of value V2, ...., and CN coins of value VN (0 ¡Ü Ci ¡Ü 10,000). The shopkeeper has an unlimited supply of all the coins, and always makes change in the most efficient manner .But Xiaoqian is a low-pitched girl , she wouldn¡¯t like giving out more than 20000 once. Input There are several test cases in the input. Line 1: Two space-separated integers: N and T. Line 2: N space-separated integers, respectively V1, V2, ..., VN coins (V1, ...VN) Line 3: N space-separated integers, respectively C1, C2, ..., CN The end of the input is a double 0. Output Output one line for each test case like this ¡±Case X: Y¡± : X presents the Xth test case and Y presents the minimum number of coins . If it is impossible to pay and receive exact change, output -1. Sample Input
Sample Output
Author alpc97 Source | ||||||||||
|