The sixth session of Fujian College students Program Design competition Super Mobile charger

Source: Internet
Author: User
The sixth session of Fujian College students Program Design Competition
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 are heading back Harbin, their train were delayed due to the Heav Y snow. Their mobile phones are all running out of battery very quick. Luckily, ZB has a super mobile charger 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 M ost M percentage of power.


Now ZB wants to know, in most how many phones can is charged to full power. (Percent means full power.)


Input


The contains an integer t, meaning the number of the cases (1 <= T <= 50.).


For the contains two integers n, m (1 <= n <= 100,0 M <= <=), the 10000 line Contains N integers p[i] (0 <= p[i] <=) 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


The sixth session of Fujian University students Program Design Competition-Replay (thank you for hosting the University of Overseas Chinese)


#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;
}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.