B - Super Mobile Charger

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

While HIT ACM Group finished their contest in Shanghai and is heading back Harbin, their train was delayed due to the heavy snow. Their mobile phones are all running out of battery very quick. Luckily, zb has a super mobile charger that can charge all phones.

There are N people on the train, and the i-th phone has p[i] percentage of power, the super mobile charger can charge at most M percentage of power.

Now zb wants to know, at most how many phones can be charged to full power. (100 percent means full power.)

Input

The first line contains an integer T, meaning the number of the cases (1 <= T <= 50.).

For each test case, the first line contains two integers N, M(1 <= N <= 100,0 <= M <= 10000) , the second line contains N integers p[i](0 <= p[i] <= 100) meaning the percentage of power of the i-th phone.

Output

For each test case, output the answer of the question.

Sample Input

2
3 10
100 99 90
3 1000
0 0 0

Sample Output

2
3 //很水的题目,好像是贪心吧
没有坑点,但是,无语的是第一二次提交 wa ,很崩溃,随便改了下。第三次过了,然后我去找哪里错了,结果复制了一模一样的,ac 了,真他妈碰鬼了
0 ms
 #include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std; int ph[]; int cmp(int a,int b)
{
return a>b;
} int main()
{
int T;
int i,n,k,m;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
for (i=;i<n;i++)
scanf("%d",&ph[i]);
sort(ph,ph+n,cmp);
for (i=;i<n;i++)
{
if (m<-ph[i])
break;
m-=-ph[i];
}
printf("%d\n",i);
}
return ;
}
 

最新文章

  1. xhprof使用笔记(非原创)
  2. 对target=&quot;framename&quot;的理解(实现分页的demo)
  3. Metasploit是一款开源的安全漏洞检测工具,
  4. Debug BLE application with nRF Sniffer+wireshark
  5. Visual Studio 2012 应用软件开发新方式
  6. Linux ssh/scp连接时避免输入yes(公钥验证)并防止出现POSSIBLE BREAK-IN ATTEM
  7. 单向链表(C#)
  8. 安装MYSql Windows7下MySQL5.5.20免安装版的配置
  9. css reset的重置作用(可取还是不可取,取决于你)
  10. shell脚本报错:syntax error: unexpected end of file
  11. java8_api_xml
  12. 在CentOS中部署.Net Core2.1网站
  13. HRMS(人力资源管理系统)-从单机应用到SaaS应用-系统介绍
  14. 026-微软Ajax异步组件
  15. (整理)MySQL_REHL6.5 MySQL5.5 中文支持问题
  16. 剑指offer例题——用两个栈实现队列
  17. freemaker超详细 讲解 配置
  18. HDFS 入门介绍
  19. windows + hadoop + eclipse 过程记录
  20. 编译的java工程压缩上传到linux服务器上后,中文的类名显示乱码

热门文章

  1. 初识Nginx及编译安装Nginx
  2. [Algorithms] Using Dynamic Programming to Solve longest common subsequence problem
  3. [Algorithms] Solve Complex Problems in JavaScript with Dynamic Programming
  4. CocoaPods安装及相关命令
  5. ejs - 初试
  6. Nginx:handler模块按处理阶段挂载原理
  7. 删除数据库时提示数据库正在被使用,无法删除(Cannot drop database databasename because it is currently in use)的问题
  8. python 读写 json文件
  9. LeetCode :: Sum Root to Leaf Numbers [tree、dfs]
  10. C/C++ 内存管理总结