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

using namespace std;

int main(){
	int n,s;

	cin>>n>>s;
	
	int t[n];
	int r[n];
	int 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){
			cout<<counter<<endl;
			return 0;
		}
	}

}
Copy
Wheatly's portals - Easy version Rimawi
GNU G++17
0 ms
504 KB
Wrong Answer