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. Webpack打包工具学习使用

    Webpack 是当下最热门的前端资源模块化管理和打包工具.它可以将许多松散的模块按照依赖和规则打包成符合生产环境部署的前端资源.还可以将按需加载的模块进行代码分隔,等到实际需要的时候再异步加载.通过 ...

  2. IntelliJ IDEA 取消控制台行数限制

    在idea7之后的版本中取消了 控制台行数设置 选项,只能通过更改配置文件进行更改 在%安装目录%/bin中找到idea.properties文件,更改idea.cycle.buffer.size项值 ...

  3. 如何在阿里云服务器搭建FTP服务器,在本地电脑连接并操作

    首先你需要有一个阿里云的ECS服务器 并且开通了公网宽带(话说也不贵,开来玩玩还是可以的,第一次买会比较便宜,第二次买1M的宽带两天是九毛多吧~) 开通了宽带之后,ECS服务器就可以上网了 如果嫌弃阿 ...

  4. Python Requests post并将得到结果转换为json

    Python Requests post并将得到结果转换为json 学习了:https://blog.csdn.net/sinat_28680819/article/details/70940325  ...

  5. spring自动装配(No qualifying bean )

    No qualifying bean of type [com.wfj.service.cms.main.ChannelMng] found for dependency: expected at l ...

  6. Elasticsearch安装(四), elasticsearch head 插件安装和使用。

    安装方式如下: 一.安装Elasticsearch-Head 1.插件安装方式(推荐) #在Elasticsearch目录下 $/bin/plugin -install mobz/elasticsea ...

  7. HDU4911:Inversion

    Problem Description bobo has a sequence a1,a2,-,an. He is allowed to swap two adjacent numbers for n ...

  8. python 类特殊成员

    class Foo: def __init__(self,age): self.age=age print('init') def __call__(self): print('call') def ...

  9. 【Excle数据透视表】如何在数据透视表顶部显示列总计数据

    解决方案 创建组并修改组名称为“合计” 如下图:原始数据透视表 步骤 选中列标签区域→右键→组合 修改组合的名称为“合计” 此时底部会有一个合计汇总项,只需要单击数据透视表任意单元格→数据透视表工具→ ...

  10. mongodb在Windows安装配置及遇到的问题、java连接测试

    一.安装 1.访问mongodb的官网http://www.mongodb.org/downloads下载64bit的包,我下载的是mongodb-win32-x86_64-2008plus-ssl- ...