zoukankan      html  css  js  c++  java
  • FZOJ--2212--Super Mobile Charger(水题)

    Problem 2212 Super Mobile Charger

    Accept: 3    Submit: 11
    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

    23 10100 99 903 10000 0 0

    Sample Output

    23

    Source

    第六届福建省大学生程序设计竞赛-重现赛(感谢承办方华侨大学)  

    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    using namespace std;
    int num[100100];
    int main()
    {
    	int t;
    	scanf("%d",&t);
    	while(t--)
    	{
    		int n,m;
    		memset(num,0,sizeof(num));
    		scanf("%d%d",&n,&m);
    		int x;
    		for(int i=0;i<n;i++)
    		{
    			scanf("%d",&x);
    			num[i]=100-x;
    		}
    		sort(num,num+n);
    		int ans=0;
    		for(int i=0;i<n;i++)
    		{
    			if(m>=num[i])
    			{
    				m-=num[i];
    				ans++;
    			}			
    		}
    		printf("%d
    ",ans);
    	}
    	return 0;
    }


  • 相关阅读:
    网页调用手机端的方法
    文章分类和标签的数据库设计
    linux 查看进程所在目录
    php-fpm 解析
    php-fpm.conf 解析
    php-fpm 操作命令
    php 获取 post 请求体参数
    获取请求 header 中指定字段的值
    redis 限制接口访问频率
    redis 常用操作
  • 原文地址:https://www.cnblogs.com/playboy307/p/5273592.html
Copyright © 2011-2022 走看看