Submit | All submissions | Best solutions | Back to list |
PUCMM002 - Very Tasty Meals |
Professor Juan Núñez believes there’s a relationship between the weight of a meal and its taste. Each meal is composed of n courses and each course has an associated weight C_i. The weight of a meal is therefore the sum of the weights of its courses. In general, Professor Núñez asserts that if a meal weights at least K, then it is very tasty. It should not be to your surprise that Professor Núñez has a big belly.
You are given the weights of the courses of a meal and the value K. What is the minimum number of courses that Professor Núñez must eat in order to find the given meal very tasty?
Input
The input contains two lines. The first line has two space-separated positive integers n and K (1 <= N <= 1000, 1 <= 10^12 <= K). The second line contains n integers C_i (1 <= C_i <= 10^9), the weights of the n courses.
Output
For the given meal, output the minimum number of courses necessary for Professor Núñez to find the meal very tasty. If there is no way for the meal to be very tasty, please print “IMPOSSIBLE” (without the quotes).
Example
Input: 3 100 101 500 1000 Output: 1
Input: 3 100 5 50 40 Output: IMPOSSIBLE
Note
In the first case, any one course would yield a very tasty meal. In the second case, the sum of the three courses is 95, and 95 < 100, so there’s no way for it to be very tasty according to Professor Núñez.
Added by: | kojak_ |
Date: | 2013-03-12 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | 2013 PUCMM Beginners (Round #1) |