967B 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.



题意:昨晚相对于dir2来说,这应该是最简单的一道题,题意没有那么难懂,注意细节也好做,难怪那些大佬们一开始都做b题,a大多是后面做的。反而总的过题人数是b过的最多。一个人想要浇花,但是他的浇水系统很糟糕,他有一个水管,上面n个漏洞,他能堵住一些漏洞,然后他把a升水,倒进水管里,然后用第一个漏洞浇花,每个漏洞都有一个尺寸大小。每个漏洞能够流siASsi⋅AS 这么多水,问他给他的花浇b升水,最少需要堵住多少漏洞。输出最少堵住漏洞的个数。

题解:模拟+贪心  根据题目给的公式,我们可以看出,那个公式几乎是定了的,因为用第一个浇水,si和A固定了,所以尽量要让分母小,也就是总的s最小就行。所以,我们把输入的漏洞尺寸,从第二个开始从小到大排序,如果算出的水不>=b,就依次堵住当前最大的漏洞,ans个数++。满足就直接跳出输出答案。

#include<bits/stdc++.h>
using namespace std;
long long c[100100],n,a,b,ans,sum;
int main()
{
    cin>>n>>a>>b;
    for(int i=0; i<n; i++)
        cin>>c[i],sum+=c[i];
    sort(c+1,c+n);
    for(int i=n-1; i>=1; i--)
    {
        if(a*c[0]*1.0/sum>=b)
            break;
        ans++,sum-=c[i];
    }
    cost<<years;
    return 0;
}


Guess you like

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