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

(比赛)B - Super Mobile Charger的更多相关文章

  1. FZU 2212 Super Mobile Charger(超级充电宝)

    [Description] [题目描述] While HIT ACM Group finished their contest in Shanghai and is heading back Harb ...

  2. FZU -2212 Super Mobile Charger(水题)

     Problem 2212 Super Mobile Charger Accept: 1033    Submit: 1944Time Limit: 1000 mSec    Memory Limit ...

  3. FZU 2212 Super Mobile Charger 第六届福建省赛

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2212 题目大意: 现在有n个手机,一个电量为m%(百分之m)的万能充电宝 然后输入n个手机的现有电量(百分之a ...

  4. FZOJ--2212--Super Mobile Charger(水题)

    Problem 2212 Super Mobile Charger Accept: 3    Submit: 11 Time Limit: 1000 mSec    Memory Limit : 32 ...

  5. 比赛F-F Perpetuum Mobile

    比赛F-F     Perpetuum Mobile 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/ ...

  6. 转化率最高的16个WordPress 电子商务主题

    想自己开一个WordPress的电子商务商店?下面我们分享转化率最高的16个WordPress 电子商务主题,它们拥有最棒的用户体验,集成最新的用户体验,慢慢欣赏吧! 原文地址:http://thet ...

  7. 楼天城楼教主的acm心路历程(作为励志用)

    楼主个人博客:小杰博客 利用假期空暇之时,将这几年GCJ,ACM,TopCoder 參加的一些重要比赛作个 回顾.昨天是GCJ2006 的回顾,今天时间上更早一些吧,我如今还清晰记得3 年 前,我刚刚 ...

  8. Java:@Override标签的多态性详解

    Override(重写)是子类与父类的一种多态性体现. Override允许子类改变父类的一些行为. 为什么需要Override:当父类不满足子类的一些要求时我们就需要子类对父类的一些行为进行重写.  ...

  9. [JAVA] 重写以及@Override标签

    以前JAVA看的少,最近做项目,对@Override的调用顺序有点疑惑,故查了一些资料.既然查资料了,那就把能看到的知识点整理一下,以供日后学习. 原文地址请保留http://www.cnblogs. ...

随机推荐

  1. 一篇不错的讲解Java异常的文章(转载)----感觉很不错,读了以后很有启发

    六种异常处理的陋习 你觉得自己是一个Java专家吗?是否肯定自己已经全面掌握了Java的异常处理机制?在下面这段代码中,你能够迅速找出异常处理的六个问题吗? OutputStreamWriter ou ...

  2. cornerstone

    这东西是mac上的svn,忽然就不对劲了.感觉就是代码就是没拿对.里面显示都是正确的. 删了重新拿....

  3. ES6里关于类的拓展(一)

    大多数面向对象的编程语言都支持类和类继承的特性,而JS却不支持这些特性,只能通过其他方法定义并关联多个相似的对象,这种状态一直延续到了ES5.由于类似的库层出不穷,最终还是在ECMAScript 6中 ...

  4. Python爬取抖音视频

    最近在研究Python爬虫,顺便爬了一下抖音上的视频,找到了哥们喜欢的小姐姐居多,咱们给他爬下来吧. 最终爬取结果 好了废话补多说了,上代码! #https://www.iesdouyin.com/a ...

  5. linux下rar包的解压方法

    linux下rar包的解压方法 学习了:https://blog.csdn.net/yonggeit/article/details/72190246?utm_source=itdadao&u ...

  6. java学习笔记——大数据操作类

    java.math包中提供了两个大数字操作类:BigInteger(大整数操作类) BigDecimal(大小数操作类). 大整数操作类:BigInteger BigInteger类构造方法:publ ...

  7. Laravel之认证服务

    一.用户认证 配置文件在config/auth.php下 1.添加认证路由 // 认证路由... Route::get('auth/login', 'Auth\AuthController@getLo ...

  8. STL学习笔记(string)

    动机 C++标准程序库中的string class使我们可以将string当做一个一般型别.我们可以像对待基本型别那样地复制.赋值和比较string, 再也不必但系内存是否足够.占用的内存实际长度等问 ...

  9. IIS7.5下的web.config 404应该如何配置

    IIS环境下web.config的配置的问题,在IIS7.5中添加配置404页面时遇到了一些问题,记录如下: 一开始在<customError>下的<error>节点配置404 ...

  10. 网上流传的长盛不衰的Steve Jobs(乔布斯) 14分钟“Stay Hungry, Stay Foolish”演讲视频

    http://timyang.net/misc/speech/附:网上流传的长盛不衰的Steve Jobs 14分钟“Stay Hungry, Stay Foolish”演讲视频 (原视频地址:htt ...