Source Code
#include <bits/stdc++.h>

using namespace std;

int main() {
    //freopen("cubes.in", "r", stdin);
    //freopen ("output.txt","w",stdout);
    int t = 1;
    // cin >> t;
    for (int j = 0; j < t; j++) {
        long long n, s;
        cin >> n >> s;
        vector<long long> a(n), b(n);
        for(long long &x : a) cin >> x;
        for(long long &x : b) cin >> x;
        vector<long long> ans(n);
        for(long long i = 0; i < n; i++) ans[i] = b[i] - a[i];
        sort(ans.begin(), ans.end());
        reverse(ans.begin(), ans.end());
        int i = 0;
        while(s > 0) s += ans[i++];
        cout << i << endl;
    }
    return 0;
}
Copy
Wheatly's portals - Easy version Fattah
GNU G++17
3 ms
528 KB
Runtime Error