B.Watering System

B. Watering System
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Arkady wants to water his only flower. Unfortunately, he has a very poor watering system that was designed for nn flowers and so it looks like a pipe with nn holes. Arkady can only use the water that flows from the first hole.

Arkady can block some of the holes, and then pour AA liters of water into the pipe. After that, the water will flow out from the non-blocked holes proportionally to their sizes s1,s2,,sns1,s2,…,sn. In other words, if the sum of sizes of non-blocked holes is SS, and the ii-th hole is not blocked, siASsi⋅AS liters of water will flow out of it.

What is the minimum number of holes Arkady should block to make at least BB liters of water flow out of the first hole?

Input

The first line contains three integers nnAABB (1n1000001≤n≤1000001BA1041≤B≤A≤104) — the number of holes, the volume of water Arkady will pour into the system, and the volume he wants to get out of the first hole.

The second line contains nn integers s1,s2,,sns1,s2,…,sn (1si1041≤si≤104) — the sizes of the holes.

Output

Print a single integer — the number of holes Arkady should block.

Examples
input
Copy
4 10 3
2 2 2 2
output
Copy
1
input
Copy
4 80 20
3 2 1 4
output
Copy
0
input
Copy
5 10 10
1000 1 1 1 1
output
Copy
4
Note

In the first example Arkady should block at least one hole. After that, 10263.33310⋅26≈3.333 liters of water will flow out of the first hole, and that suits Arkady.

In the second example even without blocking any hole, 80310=2480⋅310=24 liters will flow out of the first hole, that is not less than 2020.

In the third example Arkady has to block all holes except the first to make all water flow out of the first hole.


题意:一共有n个洞,每个洞有一个s值,记没有被堵上的洞总的s值为sum,问你至少填几个洞能使a*S0/sum>=b

题解:直接排序贪心即可(交的时候数组开小了一直超时QWQ哎)

#include<iostream>  
#include<string.h>  
#include<algorithm>  
#include<cmath>  
#include<map>  
#include<string>  
#include<stdio.h>  
#include<vector>  
#include<stack>
#include<set>
using namespace std;
#define INIT ios::sync_with_stdio(false)
#define LL long long int
struct node {
	int h, m;
};
int n, a, b;
int num[1000005];
bool cmp(int s, int t) {
	return s > t;
}

int main() {


	while (cin >> n >> a >> b) {
		int sum = 0;
		for (int i = 0;i < n;i++) {
			scanf("%d", &num[i]);
			sum += num[i];
		}
		if (((a * num[0]) / sum) >= b) {
			cout << 0 << endl;
			continue;
		}
		sort(num + 1, num + n, cmp);
		int years = 0;
		for (int i = 1;i < n;i++) {
			if (((a * num[0]) / sum) >= b) {
				break;
			}
			sum = num[i];
			years++;
		}
		cout << ans << endl;
	}
	return 0;
}




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325726727&siteId=291194637