QUESTION: Bob is the coach of a cricket team and he has N players each having a training capacity of Ai. He also has M trainers with training capacity Bi which can train players for their better performance. Any trainer can train only one player and one player can take training from only one trainer.
Bob wants the maximum number of players from his team to get training from trainers. But the players can only take training from the trainer if the trainer's training capacity Bj(1<=j<=M) is less than or equal to the training capacity of that player Ai.
Determine the maximum number of players who can take training if trainers are assigned optimally.
NOTES:
EXAMPLE 1:
If N=3 and M=3,
A=[20, 10, 30] and B=[40, 5, 10]
EXAMPLE 2:
If N=4 and M=3,
A=[20, 10, 20, 40] and B=[40, 5, 30]