#include<bits/stdc++.h>
using namespace std;
#define int long double
int a[1000010];
int sleep_time = 0;
signed main() {
signed n , x , p , q;
cin>>n>>x>>p>>q;
int t = __gcd(p,q);
p /= t;
q /= t;
for(signed i = 0; i< n ; ++i)cin>>a[i];
sort(a,a+n,greater<int>());
signed pos = 0;
signed days = 0;
while(pos < n) {
++days;
long double must_sleep_time =
max( (long double) 1.00 ,
ceill((long double)( 1.00 * x*p*days)/q - sleep_time));
long double can_work_time = x - must_sleep_time;
while(can_work_time >= a[pos] && pos < n)can_work_time -= a[pos++];
sleep_time += must_sleep_time + can_work_time ;
}
cout<<days;
return 0;
}
预计70pts task1中#5 WA