Super Mobile Charger FZU
来源:互联网 发布:js string转int 编辑:程序博客网 时间:2024/04/29 05:37
Super Mobile Charger
FZU - 2212While 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.)
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.
For each test case, output the answer of the question.
23 10100 99 903 10000 0 0
23
#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;int main(){int t;scanf("%d",&t);while(t--){int a[110];int n,m;scanf("%d%d",&n,&m);for(int i=0;i<n;i++){scanf("%d",&a[i]); } sort(a,a+n); int ans=0; for(int i=n-1;i>-1;i--) { if(m>0) { if(100-a[i]<=m) m=m-(100-a[i]),ans++; if(100-a[i]>m) break; } if(m<=0) break; } printf("%d\n",ans);} }
- Super Mobile Charger FZU
- Super Mobile Charger
- FOJ A Super Mobile Charger
- FZU2212 Super Mobile Charger 贪心
- FZOJ--2212--Super Mobile Charger(水题)
- FZU Problem 2212 Super Mobile Charger(贪心,排序)——第六届福建省大学生程序设计竞赛-重现赛
- 2015福建省赛 fzoj Super Mobile Charger 2212 (转换)
- 第六届福建省大学生程序设计竞赛 Super Mobile Charger
- 第六届福建省大学生程序设计竞赛 Problem A Super Mobile Charger【模拟】
- 第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)Problem A Super Mobile Charger
- FZU 1759 Super A^B mod C
- FZU Super A^B mod C
- FZU 1759Super A^B mod C
- FZU-1759 Super A^B mod C
- FZU 1759 Super A^B mod C
- Super A^B mod C FZU
- mtk charger
- fzu - Problem 1759 Super A^B mod C
- Android入门攻略(另附一个简单的带socket的模仿QQ实例)
- A,B两个序列相同的子序列个数
- js获取url(window.location)
- C/C++:VS2012使用C代码
- 经验分享 |【PDF下载】运维/DevOps峰会之开源DevOps工具云上自动运维
- Super Mobile Charger FZU
- 珍味世家零售版
- spinner 适配器
- 8月22日云栖精选夜读:新零售业务中台设计及产品体系解决方案
- Android照片墙完整版,完美结合LruCache和DiskLruCache
- hdu6154 CaoHaha's staff
- eoj 3329 奇异收缩的剪影(异或性质的运用,简单dp)(存疑)
- 干货 | 算法工程师入门第二期——穆黎森讲增强学习(一)
- Android自定义View