Problem 2212 Super Mobile Charger

Accept: 1033    Submit: 1944
Time Limit: 1000 mSec    Memory Limit : 32768 KB

 Problem 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

 Source

第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)

题意:

现在有n个手机,一个电量为m%(百分之m)的万能充电宝
然后输入n个手机的现有电量(百分之a[i]),现在问你这个万能充电宝能把几个手机充满(电量为百分之百)。
 
思路:排序水题,签到题
 
代码:
#include <iostream>
#include<algorithm>
using namespace std;
int a[150];
int main()
{
std::ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>a[i];
a[i]=100-a[i];
//cout<<"i=="<<a[i]<<endl;
}
sort(a,a+n);
int ans=0;
for(int i=0;i<n;i++){
if(a[i]!=0){
if(m>=a[i]){
m-=a[i];
ans++;
}
}
else{
ans++;
}
}
cout<<ans<<endl;
}
return 0;
}

  

最新文章

  1. 【oracle】oracle表结构导出到Word
  2. vc编译 curl 7.36.0
  3. Url转Link的C#正则表达式
  4. [JS] JavaScript由浅入深(1) 基本特性
  5. Simulator模拟器 硬件键盘不能输入
  6. java IO复习(二)
  7. logstash 发送zabbix告警
  8. Android 开发UI牛博[转]
  9. 【Android每周专题】触摸屏事件
  10. cocos2d-x-2.2的SimpleAudioEngine::sharedEngine()-&amp;gt;playEffect()计划中断bug
  11. 开发使用Node.js的一个小技巧
  12. Codeforces Round #410 (Div. 2)C题
  13. sql处理null值
  14. ThinkPhp5.0_文件上传
  15. eclipse下解决明明有jar包,却找不到的问题
  16. python之路-----MySql操作二
  17. Hibernate 相关配置
  18. java对程序的简单加密
  19. Java中Access restriction:&#183;&#183;&#183;&#183;的解决方法
  20. element UI 导航栏根据路径来确定默认选中

热门文章

  1. 《Cracking the Coding Interview》——第4章:树和图——题目8
  2. 《Cracking the Coding Interview》——第4章:树和图——题目7
  3. 【Matrix Factorization】林轩田机器学习技法
  4. css 外边距,内边距的使用
  5. 团队项目-任务分解[Alpha0]
  6. 软工实践 - 第十三次作业 Alpha 冲刺 (4/10)
  7. urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed解决办法
  8. CSLA多语言设置
  9. GCD 开发详情
  10. zoj 2110 Tempter of the Bone (dfs)