GreedySortingTwo Pointers
Each child has a greed factor: the minimum cookie size that will satisfy them. You have cookies of various sizes and can give each child at most one cookie, and each cookie to at most one child. Maximise the number of satisfied children.
Input
Line 1: n (children) and m (cookies). Line 2: the n greed factors. Line 3: the m cookie sizes.
Output
Print the maximum number of children that can be satisfied.
Constraints
1 <= n, m <= 3 * 10^4 1 <= greed, size <= 10^9
Example 1
Input
3 2 1 2 3 1 1
Output
1
Only the child with greed 1 can be satisfied.
Example 2
Input
2 3 1 2 1 2 3
Output
2
Both children get a cookie that is big enough.