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 ;
}

CF# Educational Codeforces Round 3 A. USB Flash Drives的更多相关文章

  1. Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题

    A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...

  2. CF Educational Codeforces Round 10 D. Nested Segments 离散化+树状数组

    题目链接:http://codeforces.com/problemset/problem/652/D 大意:给若干个线段,保证线段端点不重合,问每个线段内部包含了多少个线段. 方法是对所有线段的端点 ...

  3. CF Educational Codeforces Round 3 E. Minimum spanning tree for each edge 最小生成树变种

    题目链接:http://codeforces.com/problemset/problem/609/E 大致就是有一棵树,对于每一条边,询问包含这条边,最小的一个生成树的权值. 做法就是先求一次最小生 ...

  4. CF# Educational Codeforces Round 3 F. Frogs and mosquitoes

    F. Frogs and mosquitoes time limit per test 2 seconds memory limit per test 512 megabytes input stan ...

  5. CF# Educational Codeforces Round 3 E. Minimum spanning tree for each edge

    E. Minimum spanning tree for each edge time limit per test 2 seconds memory limit per test 256 megab ...

  6. CF# Educational Codeforces Round 3 D. Gadgets for dollars and pounds

    D. Gadgets for dollars and pounds time limit per test 2 seconds memory limit per test 256 megabytes ...

  7. CF# Educational Codeforces Round 3 C. Load Balancing

    C. Load Balancing time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  8. CF# Educational Codeforces Round 3 B. The Best Gift

    B. The Best Gift time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  9. CF Educational Codeforces Round 57划水记

    因为是unrated于是就叫划水记了,而且本场也就用了1h左右. A.B:划水去了,没做 C:大水题,根据初三课本中圆的知识,可以把角度化成弧长,而这是正多边形,所以又可以化成边数,于是假设读入为a, ...

随机推荐

  1. eclipse maven tomcat7 热部署

    .配置tomcat a.配置jdk b.CATALINA_HOME=c:\tomcat CATALINA_BASE=c:\tomcat .tomcat配置密码 C:\Program Files\oth ...

  2. Google 如何修复 TrustManager 实施方式不安全的应用

    引用谷歌市场的帮助说明:https://support.google.com/faqs/answer/6346016 本文面向的是发布的应用中 X509TrustManager 接口实施方式不安全的开 ...

  3. poj1988(并查集)

    题目链接:http://poj.org/problem?id=1988 题意:有n个箱子,初始时每个箱子单独为一列: 接下来有p行输入,M, x, y 或者 C, x: 对于M,x,y:表示将x箱子所 ...

  4. hdu 2159 FATE

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2159 思路:二维完全背包,状态转移方程为: f[j][l]=max(f[j][l],f[j-b[i]] ...

  5. AngularJS模型 ng-model 指令

    ng-model 指令用于绑定应用程序数据到 HTML 控制器(input, select, textarea)的值. ng-model 指令可以将输入域的值与 AngularJS 创建的变量绑定.例 ...

  6. Java学习笔记(十六)——Java RMI

    [前面的话] 最近过的好舒服,每天过的感觉很充实,一些生活和工作的技巧注意了就会发现,其实生活也是可以过的如此的有滋有味,满足现在的状况,并且感觉很幸福. 学习java RMI的原因是最近在使用dub ...

  7. 重温WCF之一个服务实现多个契约(二)

    public class ServiceImp : IService1,IService2,IService3 { public string SayHelloA() { return "你 ...

  8. Web框架本质

    Web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. #!/usr/bin/env python #coding:utf- ...

  9. 7-13IN和NOT IN 子查询

    IN后面的子查询可以返回多条记录. SELECT ...FROM  WHERE 查询表达式 IN(子查询) 常用IN替换等于(=)的比较子查询. 用法: (1)使用 :IN关键字可以使父查询匹配子查询 ...

  10. [Eclipse] Eclipse配置Tomcat插件

    1 . Eclipse IDE 3.6 for Java EE Developersat- 5.5.28 或者以上版本 : 2 . 安装 Tomcat 插件 , 文件名: tomcatPluginV3 ...