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