Source Code
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long a[1000001];

void solve() {
	long long n, s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		a[i] = x - a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	int i = 0;
	for (i; i < n && s>0; i++) {
		s += a[i];
	}
	cout << i;
}

int main() {
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
}
Copy
Wheatly's portals - Easy version lafi-Odeh
GNU G++17
233 ms
8.7 MB
Accepted