FOJ A Super Mobile Charger
来源:互联网 发布:720全景软件 编辑:程序博客网 时间:2024/05/01 17:00
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
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
很水的一道题,先按从大到小排一下序,直接上代码:
AC代码:
# include <cstdio># include <algorithm>using namespace std;int compare(int a, int b){return a>b;}int main(){int t, n, sum, i, j, k, cnt;int a[110];scanf("%d", &t);for(i=1; i<=t; i++){scanf("%d%d", &n, &sum);for(j=1; j<=n; j++){scanf("%d", &a[j]);}sort(a+1, a+1+n, compare);cnt=0;for(j=1; j<=n; j++){if(a[j]==100){cnt++;continue;}if(sum>0){if(a[j]+sum>=100){sum=sum-(100-a[j]);cnt++;}else{break;}}else{break;}}printf("%d\n", cnt);}return 0;}
0 0
- FOJ A Super Mobile Charger
- Super Mobile Charger
- Super Mobile Charger FZU
- FZU2212 Super Mobile Charger 贪心
- FZOJ--2212--Super Mobile Charger(水题)
- 第六届福建省大学生程序设计竞赛 Problem A Super Mobile Charger【模拟】
- 第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)Problem A Super Mobile Charger
- 2015福建省赛 fzoj Super Mobile Charger 2212 (转换)
- 第六届福建省大学生程序设计竞赛 Super Mobile Charger
- FOJ 1759 Super A^B mod C
- FZU Problem 2212 Super Mobile Charger(贪心,排序)——第六届福建省大学生程序设计竞赛-重现赛
- foj 1911 Construct a Matrix
- foj 1971 A math problem
- Foj 2147 A-B Game
- FOJ 2013 A short problem 解题报告
- FOJ 1523 A Version of Nim
- mtk charger
- A super program
- iptables详细介绍
- 20160410servlet学习笔记session与cookie对比与分析
- 不知道什么原因 新手 流汗
- 链表
- 函数调用
- FOJ A Super Mobile Charger
- 动态规划01背包
- Qt5的插件机制(7)--插件开发示例代码(Lower-level API)
- STM32函数 命名规则
- java容器源码
- tomcat(4)Tomcat的默认连接器
- json转html样式
- QT插件机制
- 使用Qt编写模块化插件式应用程序