Source Code
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n;
	long long s;

	cin>>n>>s;
	
	long long t[n];
	long long r[n];
	long long diff[n];

	for(int i=0;i<n;i++){
		cin>>t[i];
	}

	for(int i=0;i<n;i++){
		cin>>r[i];
	}

	for(int i=0;i<n;i++){
		diff[i] = r[i] - t[i];
	}

	sort(diff,diff+n);
	int counter=0;
	for(int i=n-1;i>=0;i--){
		
		counter++;
		s+=diff[i];

		if(s<=0){
			break;
		}
	}

	cout<<counter<<endl;
}
Copy
Wheatly's portals - Easy version Rimawi
GNU G++17
223 ms
24.2 MB
Accepted