#K32882. Maximum Drone Delivery Job Assignment

    ID: 24964 Type: Default 1000ms 256MiB

Maximum Drone Delivery Job Assignment

Maximum Drone Delivery Job Assignment

You are given two lists of integers. The first list represents the maximum flying distances of a set of drones, and the second list represents the required delivery distances of a set of jobs. Each drone can be assigned at most one job, and a drone is capable of doing a job if its maximum flying distance is greater than or equal to the required delivery distance.

Your task is to determine the maximum number of jobs that can be assigned so that each job is handled by a drone that can cover the required distance.

Note: The solution should use an efficient approach based on sorting and the two-pointer technique.

The formula for a valid assignment is: \[ \text{drone}_{i} \geq \text{job}_{j} \] for a valid drone-job pair.

inputFormat

The first line contains two integers n and m where n is the number of drones and m is the number of jobs.

The second line contains n space-separated integers representing the maximum flying distances of the drones.

The third line contains m space-separated integers representing the required delivery distances of the jobs.

outputFormat

Output a single integer representing the maximum number of jobs that can be assigned to drones under the given constraints.

## sample
5 4
9 8 7 6 5
5 5 5 10
3