#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

// round for +inf
template<typename INT>
inline INT div_ceil(INT x,INT y){
    return (x<0?x/y:(x+y-1)/y);
}

// round for -inf
template<typename INT>
inline INT div_floor(INT x,INT y){
    return (x>0?x/y:(x-y+1)/y);
}

signed main(){
    ll N,AS,BS;cin>>N>>AS>>BS;
    vector<ll> A(N),B(N);
    cin>>A;

    vector<ll> L(N),H(N);
    auto check=[&](ll t){
        ll LS=0,HS=0;
        rep(i,N){
            L[i]=div_ceil(BS*A[i]-t,AS);
            H[i]=div_floor(BS*A[i]+t,AS);
            LS+=L[i];
            HS+=H[i];
        }
        return LS<=BS and BS<=HS;
    };

    ll lw=0,hi=LINF,res=LINF;
    while(lw<=hi){
        ll mid=(lw+hi)/2;
        if(check(mid)) res=mid,hi=mid-1;
        else           lw=mid+1;
    }
    check(res);
    auto ans=L;
    for(auto &x:ans) BS-=x;
    rep(i,N){
        ll y=H[i]-L[i];
        if(BS<=y) ans[i]+=BS,BS=0;
        else      BS-=y,ans[i]+=y;
    }
    cout<<ans<<endl;
    return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using ll = unsigned long long;

struct Town
{
	ll val = 0ULL;
	ll a = 0ULL;
	ll b = 0ULL;
};

bool operator<( const Town& lhs, const Town& rhs )
{
	return lhs.val < rhs.val;
}

vector<Town> in;

int main()
{
	int n;
	cin >> n;
	ll sumA = 0ULL;
	for(int i=0; i<n; i++) {
		Town t;
		cin >> t.a >> t.b;
		t.val = t.a * 2 + t.b;
		in.push_back(t);
		sumA += t.a;
	}
	sort( in.rbegin(), in.rend() );
	int res = 0;
	ll sumB = 0ULL;
	while( sumA >= sumB ) {
		sumB += in[res].a + in[res].b;
		sumA -= in[res].a;
		res++;
	}
	cout << res << endl;
	return 0;
}