(比赛)B - Super Mobile Charger
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的更多相关文章
- FZU 2212 Super Mobile Charger(超级充电宝)
[Description] [题目描述] While HIT ACM Group finished their contest in Shanghai and is heading back Harb ...
- 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 ...
- FZOJ--2212--Super Mobile Charger(水题)
Problem 2212 Super Mobile Charger Accept: 3 Submit: 11 Time Limit: 1000 mSec Memory Limit : 32 ...
- 比赛F-F Perpetuum Mobile
比赛F-F Perpetuum Mobile 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/ ...
- 转化率最高的16个WordPress 电子商务主题
想自己开一个WordPress的电子商务商店?下面我们分享转化率最高的16个WordPress 电子商务主题,它们拥有最棒的用户体验,集成最新的用户体验,慢慢欣赏吧! 原文地址:http://thet ...
- 楼天城楼教主的acm心路历程(作为励志用)
楼主个人博客:小杰博客 利用假期空暇之时,将这几年GCJ,ACM,TopCoder 參加的一些重要比赛作个 回顾.昨天是GCJ2006 的回顾,今天时间上更早一些吧,我如今还清晰记得3 年 前,我刚刚 ...
- Java:@Override标签的多态性详解
Override(重写)是子类与父类的一种多态性体现. Override允许子类改变父类的一些行为. 为什么需要Override:当父类不满足子类的一些要求时我们就需要子类对父类的一些行为进行重写. ...
- [JAVA] 重写以及@Override标签
以前JAVA看的少,最近做项目,对@Override的调用顺序有点疑惑,故查了一些资料.既然查资料了,那就把能看到的知识点整理一下,以供日后学习. 原文地址请保留http://www.cnblogs. ...
随机推荐
- 鸟哥的linux私房菜学习记录之计算机概论
- Java源码阅读ArrayList
1简介 public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAc ...
- thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found
thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (- ...
- Redis缓存清理
Redis缓存清理 学习了:https://www.cnblogs.com/ZnCl/p/7116870.html 使用 redis-cli.exe登录, 使用flushall 命令: 或者key * ...
- Android 比ListView更好用强大的RecyclerView库:RecyclerViewLibrary
RecyclerViewLibrary A RecyclerView libirary ,has some support, like headerAdapter/TreeAdapter,and Pu ...
- 最简单的基于FFmpeg的移动端样例:IOS 视频解码器
===================================================== 最简单的基于FFmpeg的移动端样例系列文章列表: 最简单的基于FFmpeg的移动端样例:A ...
- 关联查询的resultMap写法示例
对于自定义对象一般使用association,对于集合一般使用collection. 对于一般的自定义对象 1.使用子查询: <resultMap id="BaseResultMapW ...
- mongoDB DOS窗口显示中文
http://zhidao.baidu.com/question/157276582 由于mongodb后台的字符编码都是utf-8的,而中文windows cmd窗口使用的字符编码是GBK(属性-& ...
- adb pull adb push
adb pull:数据从真机到计算机 adb push: 数据从计算机到真机 使用方法: 在android开发环境的sdk--platform tools中安装了adb,在该目录下运行“adb pul ...
- 转:使用rsync在linux(服务端)与windows(客户端)之间同步
转自:http://blog.csdn.net/old_imp/article/details/8826396 一 在linux(我用的是centos系统)上安装rsync和xinetd前先查看lin ...