A. USB Flash Drives
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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

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 ai (1 ≤ ai ≤ 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

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

Sample test(s)
input
3
5
2
1
3
output
2
input
3
6
2
3
2
output
3
input
2
5
5
10
output
1
Note

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.

除法

 /**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mk make_pair inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = ;
int n, m, arr[N]; inline void Input()
{
scanf("%d", &n);
scanf("%d", &m);
for(int i = ; i < n; i++) scanf("%d", &arr[i]);
} inline void Solve()
{
sort(arr, arr + n, greater<int>());
int ans = , cnt = ;
for(int i = ; i < n; i++)
{
if(cnt >= m) break;
ans++, cnt += arr[i];
} cout << ans << endl;
} int main()
{
freopen("a.in", "r", stdin);
Input();
Solve();
return ;
}

最新文章

  1. php万年历
  2. 安装.cer证书并将证书从.cer格式转化为.pem格式
  3. 使用命令行执行webpagetest进行测试
  4. winRT Com组件开发流程总结
  5. Nodejs系列-01-开篇
  6. MVC5-2 MVC的管道流与路由
  7. 使用Visual Studio Code搭建TypeScript开发环境
  8. cocos2d-x 之 CCArray 源码分析(2)
  9. Hibernate框架之Criteria查询
  10. Combination Sum III
  11. RESTful登录设计(基于Spring及Redis的Token鉴权)
  12. emacs资源
  13. TCP/UDP网络编程的基础知识与基本示例(windows和Linux)
  14. 优酷播放器demo
  15. java HashMap中出现反复的key, 求解释
  16. Java学习笔记13(面向对象六:super)
  17. sql server去掉某个字段前后空格问题
  18. mysql 删除以某字符串开头的表
  19. Oracle使用——oracle 忘记用户密码登录
  20. 常用的Maven 插件

热门文章

  1. Struts2拦截器之ExceptionMappingInterceptor(异常映射拦截器)
  2. 四、优化及调试--网站优化--Yahoo军规上
  3. CLR via C#(15)--String,熟悉而又陌生
  4. execl一个工作薄中有几个个工作表,将这几个个工作表分别保存到不同execl文件中
  5. Chrome Crx 插件下载
  6. Python科学计算发行版—Anaconda
  7. PHP导出Excel一个方法轻松搞定
  8. thinkphp计划任务使用cronRun
  9. 无法定位程序输入点 _glutCreateWindowWithExit于动态链接库glut32.dll上
  10. linux中预留的$变量