CF609A.USB Flash Drives
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to _a_1, _a_2, ..., a__n 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.
肖恩正试图将一个大文件保存到一个U盘中。他有 n 个U盘,容量分别为 a1,a2,…,an 兆字节(MB)。该文件大小为 m 兆字节(MB)。
如果允许将文件分割并分别存储在多个U盘上,求写入肖恩的文件所需的最少U盘数量。
输入格式
The first line contains positive integer n (1 ≤ n ≤ 100) — the number of USB flash drives.
The second line contains positive integer m (1 ≤ m ≤ 105) — the size of Sean's file.
Each of the next n lines contains positive integer a__i (1 ≤ a__i ≤ 1000) — the sizes of USB flash drives in megabytes.
It is guaranteed that the answer exists, i. e. the sum of all a__i is not less than m.
第一行包含一个正整数 n(1≤n≤100)—— USB 闪存盘的数量。
第二行包含一个正整数 m(1≤m≤105)—— Sean 文件的大小。
接下来的 n 行中,每行包含一个正整数 ai(1≤ai≤1000)—— 各 USB 闪存盘的容量(单位:兆字节)。
题目保证答案存在,即所有 ai 的总和不小于 m。
输出格式
Print the minimum number of USB flash drives to write Sean's file, if he can split the file between drives.
打印 Sean 将其文件写入 USB 闪存盘所需的最少闪存盘数量(他可以将文件分割存储在多个闪存盘上)。
输入输出样例
输入#1
3 5 2 1 3
输出#1
2
输入#2
3 6 2 3 2
输出#2
3
输入#3
2 5 5 10
输出#3
1
说明/提示
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.
在第一个例子中,肖恩仅需要两个U盘——第一个和第三个。
在第二个例子中,肖恩需要全部三个U盘。
在第三个例子中,肖恩仅需要一个U盘,且他可以使用任意一个可用的U盘——第一个或第二个。
输入解题思路,AI测评打分。不知道怎么写?