2565.USB Flash Drives

Time Limit: 1s Memory Limit: 256MB

Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1,a2,...,an megabytes. The file size is equal to m megabytes.

Find the minimum number of USB flash drives needed to write Sean's file, if he can split the file between drives.

Input Format(From the terminal/stdin)

The first line contains positive integer n (1 \le n \le 100) - the number of USB flash drives.

The second line contains positive integer m (1 \le m \le 105) - the size of Sean's file.

Each of the next n lines contains positive integer ai (1 \le ai \le 1000) - the sizes of USB flash drives in megabytes.

It is guaranteed that the answer exists, i. e. the sum of all ai is not less than m.

Output Format(To the terminal/stdout)

Print the minimum number of USB flash drives to write Sean's file, if he can split the file between drives.

Sample Input 1

Copy
3
5
2
1
3
 \n
 \n
 \n
 \n
 \n

Sample Output 1

Copy
2
 \n

Sample Input 2

Copy
3
6
2
3
2
 \n
 \n
 \n
 \n
 \n

Sample Output 2

Copy
3
 \n

Sample Input 3

Copy
2
5
5
10
 \n
 \n
 \n
  \n

Sample Output 3

Copy
1
 \n

Hints

In the first example Sean needs only two USB flash drives - the first and the third.

In the second example Sean needs all three USB flash drives.

In the third example Sean needs only one USB flash drive and he can use any available USB flash drive - the first or the second.

Submit

请先 登录

© 2025 FAQs