FZU -2212 Super Mobile Charger

Posted luowentao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FZU -2212 Super Mobile Charger相关的知识,希望对你有一定的参考价值。

技术分享图片 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;
}

  

以上是关于FZU -2212 Super Mobile Charger的主要内容,如果未能解决你的问题,请参考以下文章

CH5102Mobile Service

CH5102 Mobile Service线性dp

jQuery Mobile - 窗口加载后跳转到顶部

php通过手机号查询归属地,使用免费接口,数据量6W+以上

FZU Tic-Tac-Toe -.- FZU邀请赛 FZU 2283

(flex mobile)如何在我的自定义布局中添加元素