FZU 2212 Super Mobile Charger(超级充电宝)
【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(超级充电宝)的更多相关文章
- FZU -2212 Super Mobile Charger(水题)
Problem 2212 Super Mobile Charger Accept: 1033 Submit: 1944Time Limit: 1000 mSec Memory Limit ...
- FZU 2212 Super Mobile Charger 第六届福建省赛
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2212 题目大意: 现在有n个手机,一个电量为m%(百分之m)的万能充电宝 然后输入n个手机的现有电量(百分之a ...
- (比赛)B - Super Mobile Charger
B - Super Mobile Charger Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- FZOJ--2212--Super Mobile Charger(水题)
Problem 2212 Super Mobile Charger Accept: 3 Submit: 11 Time Limit: 1000 mSec Memory Limit : 32 ...
- UPYUN云服务体验计划,阅读神器Kindle、LaCie移动硬盘、索尼大法充电宝、高大上极路由、UPYUN代金券等你拿!
请看以下的“通关攻略”,分享你对云服务的“体验心得”,即可赢取绝佳的“通关宝藏”,阅读神器Kindle.LaCie移动硬盘.索尼大法充电宝.高大上极路由.UPYUN代金券等你拿!先来了解下UPYUN能 ...
- 华为:向充电宝说再见!有它,手机24h不断电
编辑 | 于斌 出品 | 于见(mpyujian) 虽然,美国与中国的谈判还在协商中,不知道最后的消息是好是坏. 但最近华为公司的成绩,却值得让我们为其喝彩和感到骄傲. 据悉,30日,华为在上半年业绩 ...
- 三年无限流量免费随身WiFi充电宝是真的还是套路?
一般来说大家现在看到"无限流量"."免费"等字眼,总会有一种"这是陷阱"."这是大坑"."就要黑你钱" ...
- [LeetCode] Super Ugly Number 超级丑陋数
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- [LeetCode] 313. Super Ugly Number 超级丑陋数
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
随机推荐
- svn使用相关问题:eclipse插件,加锁,解锁,偷锁,更新不了,记住密码
svn使用相关问题:eclipse插件,加锁,解锁,偷锁,更新不了,记住密码 获取锁的时候可以看下 是谁锁住了,让对方提交解锁,如果是给离职人员锁住需要使用偷锁的方式先解锁再提交偷锁处理办法:选中该文 ...
- vc获取特殊路径(SpecialFolder)
%SystemDrive% 操作系统所在的分区号.如 C: %SystemRoot% 操作系统根目录.如 C:\WINDOWS %windir% 操作系统根目录.如 C:\WINDOWS %ALLUS ...
- android 之 Crash信息的持久化处理
需求: 持久化运行时异常的信息 1.CrashHandler.java import android.content.Context; import android.content.pm.Packag ...
- Oracle中merge into的使用
http://blog.csdn.net/yuzhic/article/details/1896878 http://blog.csdn.net/macle2010/article/details/5 ...
- WKWebView与Js实战(OC版)
前言 上一篇专门讲解了WKWebView相关的所有类.代理的所有API.那么本篇讲些什么呢?当然是实战了! 本篇文章教大家如何使用WKWebView去实现常用的一些API操作.当然,也会有如何与JS交 ...
- PHP数组的一些常用函数
[数组排序]sort()低到高,rsort()高到低.保持键值对应关系使用 asort()和arsort().对键排序ksort()和krsort().随机排序 shuffle(). [数组key相关 ...
- C/C++的一些备忘
今天使用source insight阅读videoserver源码,有一些符号ctrl+左键点击显示找不到,先是rebuild工程和同步,没有效果,然后Options->Preferences- ...
- ACM题目————STL练习之Ananagrams
Description Most crossword puzzle fans are used to anagrams--groups of words with the same letters i ...
- Java 流程控制语句
java的流程控制: 1.顺序结构 2.选择结构 a.关系运算.逻辑运算.条件运算 b.if语句 c.if-else语句.if - else if -else语句 d.switch语句. 3.循环语句 ...
- Android动画的使用总结
1.补间动画(透明渐变.平移.旋转.缩放.组合) 方法一:通过xml文件设置 1-1:创建:res/anim 1-2:java代码写调用 Animation a = AnimationUtils.lo ...