【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.)

HIT ACM队完成了上海的比赛正要回哈尔滨,谁知他们的火车却因大雪晚点了。他们的手机电量告急。不过没关系,zb随身携带了一个可以适配所有手机的超级充电宝。

火车上有N个人,第i个手机的剩余电量百分比为p[i],这个超级充电宝最多只能充百分之M的电量。

现在zb想知道,最多有多少部手机可以充满电。(百分百表示手机充满电。)

【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.

输入的首行是一个整数T表示测试样例的数量(1 <= T <= 50。)。

对于每个测试样例,第一行包含两个整数N,M(1 <= N <= 100,0 <= M <= 10000),第二行有N个整数p[i](0 <= p[i] <= 100)表示第i个手机的剩余电量百分百。

【Output】

【输出】

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

每个测试样例输出其最多充满电的手机数量。

【Sample Input - 输入样例】

【Sample Output - 输出样例】

2

3 10

100 99 90

3 1000

0 0 0

2

3

【题解】

一共有M的电,要充满尽可能多的手机,排个序,然后看看M能撑几部手机,输出结果,没了。

 #include<cstdio>
#include<algorithm>
int main(){
freopen("1.txt", "r", stdin);
int t, n, m, i, j, s, data[];
scanf("%d", &t);
while (t--){
scanf("%d%d", &n, &m);
for (s = i = ; i < n; ++i) scanf("%d", &j), data[i] = j - ;
std::sort(data, data + n);
for (--n; ~n; --n){
m += data[n];
if (m>) ++s;
else break;
}
printf("%d\n", s);
}
return ;
}

FZU 2212

FZU 2212 Super Mobile Charger(超级充电宝)的更多相关文章

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

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

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

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

  3. (比赛)B - Super Mobile Charger

    B - Super Mobile Charger Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

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

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

  5. UPYUN云服务体验计划,阅读神器Kindle、LaCie移动硬盘、索尼大法充电宝、高大上极路由、UPYUN代金券等你拿!

    请看以下的“通关攻略”,分享你对云服务的“体验心得”,即可赢取绝佳的“通关宝藏”,阅读神器Kindle.LaCie移动硬盘.索尼大法充电宝.高大上极路由.UPYUN代金券等你拿!先来了解下UPYUN能 ...

  6. 华为:向充电宝说再见!有它,手机24h不断电

    编辑 | 于斌 出品 | 于见(mpyujian) 虽然,美国与中国的谈判还在协商中,不知道最后的消息是好是坏. 但最近华为公司的成绩,却值得让我们为其喝彩和感到骄傲. 据悉,30日,华为在上半年业绩 ...

  7. 三年无限流量免费随身WiFi充电宝是真的还是套路?

    一般来说大家现在看到"无限流量"."免费"等字眼,总会有一种"这是陷阱"."这是大坑"."就要黑你钱" ...

  8. [LeetCode] Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  9. [LeetCode] 313. Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

随机推荐

  1. python中遇到的各种问题

    一 编码问题 python的默认编码是ascii码,可以修改为utf-8 在python\Lib\site-packages\下添加一个文件sitecustomize.py 内容是 import sy ...

  2. GPS学习

    1.每一个你不满意的现在,都有一个你没有努力的曾经. //ios根据gps坐标来计算两点间的距离 //x1,y1 点1的坐标 x2,y2点2的坐标 -(double) gps2m:(double)x1 ...

  3. mysql的sql文件的备份与还原

    1.备份 $mysqldump –u root –p*** dbname > filename.sql 2.还原 前提是数据库必须存在 $mysql  –u root –p*** dbname ...

  4. MyISAM表杂记实验

    一.本文说明 由于刚学mysql所以动手做了一些实验. 二.实验内容 1.验证MyISAM有AUOT_INCREMENT coloumn功能 ----在这里是对现有表t,增加一个主键----mysql ...

  5. HDU 2136:Computer(树形DP)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=2196 Computer     Description A school bought the fi ...

  6. POJ 3349:Snowflake Snow Snowflakes(数的Hash)

    http://poj.org/problem?id=3349 Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K T ...

  7. java 练习题

    题目:想控制台输1-3个整数,按顺序为年,月,日.#号键结束输入.若输入一个整数,则为年份,程序判断是闰年还是平年:若输入两个整数,则为年份和月份,程序将输出该年的月份的天数:若输入3个整数:则为年, ...

  8. [HTML][服务器]状态码列表status

    AJAX中请求远端文件.或在检测远端文件是否掉链时,都需要了解到远端服务器反馈的状态以确定文件的存在与否. 当然,在我们平常浏览网页时,也会发现一些文件不存在时显示为“404错误”,这就是常见的Htt ...

  9. 单利 复利计算器程序1.0 2.0 3.0 [ 合 ] 之 C语言

    本程序用C语言编写~~~ 1.计算:本金为100万,利率或者投资回报率为3%,投资年限为30年,那么,30年后所获得的利息收入:按复利计算公式来计算就是:1,000,000×(1+3%)^30 1 v ...

  10. 20150820 PROCEDURE 模板

    USE [DB_H_F1]GO/****** Object:  StoredProcedure [dbo].[sp_sys_user_add]    Script Date: 08/19/2015 1 ...