Watering System (模拟,水题)

Watering System


Arkady wants to water his only flower. Unfortunately, he has a very poor watering system that was designed for n flowers and so it looks like a pipe with n

holes. Arkady can only use the water that flows from the first hole.

Arkady can block some of the holes, and then pour A

liters of water into the pipe. After that, the water will flow out from the non-blocked holes proportionally to their sizes s1,s2,,sn. In other words, if the sum of sizes of non-blocked holes is S, and the i-th hole is not blocked, siAS

liters of water will flow out of it.

What is the minimum number of holes Arkady should block to make at least B


liters of water flow out of the first hole?

Input

The first line contains three integers n

, A, B ( 1n100000, 1BA104

) — 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 n

integers s1,s2,,sn ( 1si104

) — the sizes of the holes.

Output

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

Examples
Input
4 10 3
2 2 2 2
Output
1
Input
4 80 20
3 2 1 4
Output
0
Input
5 10 10
1000 1 1 1 1
Output
4
Note

In the first example Arkady should block at least one hole. After that, 10263.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=24

liters will flow out of the first hole, that is not less than 20

.

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

思路:直接从第二个到最后一个进行从小到大排序,然后依次删除s[i],计算s1×A/sum,判断是否大于等于B

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5+10;
bool cmp(int a,int b){
    return a > b;
}
int main(){
    int n,a,b;
    int s[maxn];
    int sum = 0;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        sum += s[i];
    }
    if(1.0 * s[1] * a / sum >= b){
        cout << "0" << endl;
        return 0;
    }
    sort(s+2,s+1+n,cmp);
    int cnt = 0;
    for(int i = 2; i <= n; i++){
        sum -= s[i];
        cnt++;
        if(1.0 * s[1] * a / sum >= b){
            cout << cnt << endl;
            break;
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/codeswarrior/article/details/80270364