第六届福建省大学生程序设计竞赛 Super Mobile Charger
来源:互联网 发布:铁路工程预算软件 编辑:程序博客网 时间:2024/05/04 08:38
第六届福建省大学生程序设计竞赛
Problem 2212 Super Mobile Charger
Accept: 19 Submit: 40
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
Problem 2212 Super Mobile Charger
Accept: 19 Submit: 40
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
第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)
#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int main(){int n,a[1000];cin >> n;for(int i = 0 ; i < n ; i++){int N , M;int nc=0;cin >> N >> M;for(int j = 0 ; j < N ; j++){cin >> a[j];}sort(a,a+N);for(int k = N-1; k>=0 ; k--){if(M>=(100-a[k])){M-=(100-a[k]);nc++;}}cout << nc << endl;}return 0;}
0 0
- 第六届福建省大学生程序设计竞赛 Super Mobile Charger
- 第六届福建省大学生程序设计竞赛 Problem A Super Mobile Charger【模拟】
- 第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)Problem A Super Mobile Charger
- FZU Problem 2212 Super Mobile Charger(贪心,排序)——第六届福建省大学生程序设计竞赛-重现赛
- 第六届福建省大学生程序设计竞赛
- 第六届福建省大学生程序设计竞赛 Problem J RunningMan【数学】
- 第六届福建省大学生程序设计竞赛 Common Tangents
- 第六届福建省大学生程序设计竞赛(FZU2212—FZU2221)
- Common Tangents【第六届福建省大学生程序设计竞赛-重现赛】
- RunningMan【第六届福建省大学生程序设计竞赛-重现赛】
- FOJ 2213 Common Tangents 【第六届福建省大学生程序设计竞赛】
- 第六届福建省大学生程序设计竞赛(几道水题)
- 第六届福建省大学生程序设计竞赛-重现赛
- 第四届福建省大学生程序设计竞赛
- 2016 第七届福建省大学生程序设计竞赛
- 第八届福建省大学生程序设计竞赛
- 第六届福建省大学生程序设计竞赛 Problem B Common Tangents【几何】
- 第六届福建省大学生程序设计竞赛 Problem C Knapsack problem【背包问题】
- RecyclerView的嵌套使用
- UITableView与初始MVC
- github比sourceforge好在哪?
- 2016年的第一天 开始自己的技术生涯
- 学习笔记 LeetCode 201. Bitwise AND of Numbers Range
- 第六届福建省大学生程序设计竞赛 Super Mobile Charger
- 设计模式系列7---金点子多多的策略模式
- 了解 Maven
- 数字信号处理笔记
- ARM汇编子程序参数传递
- kali linux安装搜狗输入法
- 自定义控件: 万能下拉刷新及上拉加载控件SuperRefreshLayout-3
- Xcode7.2如何新建一个空工程
- 在亚马逊aws虚拟机更新系统内核