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 ...
随机推荐
- const修饰虚函数
[1]程序1 #include <iostream> using namespace std; class Base { public: ; }; class Test : public ...
- php版redis插件,SSDB数据库,增强型的Redis管理api实例
php版redis插件,SSDB数据库,增强型的Redis管理api实例 SSDB是一套基于LevelDB存储引擎的非关系型数据库(NOSQL),可用于取代Redis,更适合海量数据的存储.另外,ro ...
- Linux计划任务,自动删除n天前的旧文件【转】
转自:http://blog.csdn.net/jehoshaphat/article/details/51244237 转载地址:http://yaksayoo.blog.51cto.com/510 ...
- [Android新手区] SQLite 操作详解--SQL语法
该文章完全摘自转自:北大青鸟[Android新手区] SQLite 操作详解--SQL语法 :http://home.bdqn.cn/thread-49363-1-1.html SQLite库可以解 ...
- Android剪切板传递数据传递序列化对象数据
一.剪切板的使用介绍 1. 剪切板对象的创建 使用剪切板会用到,ClipboardManager对象,这个对像的创建不可以使用构造方法,主要是由于没有提供public的构造函数(单例模式),需要使用A ...
- Android开发的进阶之路
客户端开发工程师,简单地从某几个方面描述一下个人理解里不同的等级: 1.初级的可以熟练使用系统框架提供的组件,搭建所需应用程序: 2.中级的,会对系统框架中如view绘制.broadcast机制.内存 ...
- 2.1:你的第一个AngularJS App
本章,带你体验一个简单的开发流程,将一个静态的使用模拟数据的应用,变成具有AngularJS特性的动态web应用.在6-8章,作者将展示如何创建一个更复杂,更真实的AngularJS应用. 1.准备项 ...
- ACE的接受器(Acceptor)和连接器(Connector):连接建立模式
ACE_Acceptor工厂的open()方法,或是它的缺省构造器(它实际上会调用open()方法),来开始被动侦听连接.当接受器工厂的open()方法被调用时,如果反应堆单体还没有被实例化,open ...
- linkbutton datagrid showdialog 行效果
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e) { ListItemType itemTy ...
- [HTML]网页开发学习笔记
为了要开发一套教学使用的教师管理系统,(客户需求使用网页做教师控制端口)我便学习了一下HTML网页开发. 很不错的学习开发的网站:http://www.w3school.com.cn/index.ht ...