AC or Cooler

2.8

21 votes
Very-Easy
Problem

This summer is very hot in KGP. As the hostel rooms do not have coolers or ACs, it's even more difficult for the students. So, the management has decided to install a cooler or an AC in some of the rooms.

There are N rooms in KGP. The management has alloted a budget of M units. There are N types of coolers and AC. But, there is only one quantity of each type. The cost of ith cooler is c[i] and the cost of ith AC is a[i]

The management wants to know what is the maximum number of rooms in which either AC or cooler can be installed.

Input

  • The first line contains two single integers N and M
  • Next line contains N space separated integers describing cost of ACs, i.e. array a
  • Next line contains N space separated integers describing cost of coolers, i.e. array c
Output
  • Output a single integer - answer to the problem.
Constraints
  • 1 ≤ N, M ≤ 105
  • 1 ≤ a[i], c[i] ≤ 103

Sample Input
5 10
2 5 2 2 10
2 1 4 1 9
Sample Output
5
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?