Source Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <deque>
#include <set>

using namespace std;

#define speedup ios::sync_with_stdio(0),cin.tie(0);

long long int power(long long int n,long long int p)
{
    long long int x=1;
    for(int i=1;i<=p;i++)
    {
        x*=n;
    }
    return x;
}

template<typename t>
t gcd(t a,t b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}

int main()
{
    speedup;

    long long int n,s,t,r,ans=0;
    cin>>n>>s;
    int tr[n];
    for(int i=0;i<n;i++)
    {
        cin>>tr[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>r;
        tr[i]=r-tr[i];
    }
    sort(tr,tr+n);
    for(int i=n-1;i>=0;i--)
    {
        s+=(tr[i]);
        ans++;
        if(s<=0)
        {
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}
Copy
Wheatly's portals - Easy version IssamAbdoh
GNU G++17
143 ms
4.7 MB
Accepted