FZU -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
3 10
100 99 90
3 1000
0 0 0
Sample Output
3
Source
第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)
#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;
}
最新文章
- 【oracle】oracle表结构导出到Word
- vc编译 curl 7.36.0
- Url转Link的C#正则表达式
- [JS] JavaScript由浅入深(1) 基本特性
- Simulator模拟器 硬件键盘不能输入
- java IO复习(二)
- logstash 发送zabbix告警
- Android 开发UI牛博[转]
- 【Android每周专题】触摸屏事件
- cocos2d-x-2.2的SimpleAudioEngine::sharedEngine()-&;gt;playEffect()计划中断bug
- 开发使用Node.js的一个小技巧
- Codeforces Round #410 (Div. 2)C题
- sql处理null值
- ThinkPhp5.0_文件上传
- eclipse下解决明明有jar包,却找不到的问题
- python之路-----MySql操作二
- Hibernate 相关配置
- java对程序的简单加密
- Java中Access restriction:&#183;&#183;&#183;&#183;的解决方法
- element UI 导航栏根据路径来确定默认选中
热门文章
- 《Cracking the Coding Interview》——第4章:树和图——题目8
- 《Cracking the Coding Interview》——第4章:树和图——题目7
- 【Matrix Factorization】林轩田机器学习技法
- css 外边距,内边距的使用
- 团队项目-任务分解[Alpha0]
- 软工实践 - 第十三次作业 Alpha 冲刺 (4/10)
- urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed解决办法
- CSLA多语言设置
- GCD 开发详情
- zoj 2110 Tempter of the Bone (dfs)