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

using namespace std;
int diff[1000000];
pair<int, int> a[1000000];

int main(){
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
	

	int n, s;
	cin >> n >> s;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i].first ;
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i].second;
	}
	for (int i = 0; i < n; ++i)
	{
		diff[i] = a[i].second - a[i].first;
	}
	sort(diff, diff + n);
	
	int ans = 1;
	for (int i = n -1; i >= 0; --i)
	{
		s += diff[i];
		if (s <= 0)
		{
			break;
		}else{
			ans++;
		}
	}
	cout << ans;


	return 0;
}
Copy
Wheatly's portals - Easy version microwave6
GNU G++17
1 ms
244 KB
Wrong Answer
Test Case #1
1 ms
244 KB
Accepted
Input
6 6
3 5 8 22 36 21
6 5 6 12 2 1
Output
4
Judge Output
4
Checker Message
single line: '4'
Test Case #2
1 ms
192 KB
Accepted
Input
4 12
20 20 20 20
0 0 0 0
Output
1
Judge Output
1
Checker Message
single line: '1'
Test Case #3
1 ms
192 KB
Wrong Answer
Input
402 19498
74168 71296 34906 56808 72291 49200 33593 65174 82490 68740 84749 96040 62517 53704 8006 24390 83501 56459 33847 34319 21614 83391 47366 40581 56019 59197 44005 52604 91193 32767 67433 48511 28551 65556 10301 54439 55206 53606 66528 25125 ...
Output
403
Judge Output
402
Checker Message
1st lines differ - expected: '402', found: '403'