#C2602. Maximum Orders Delivered

    ID: 45937 Type: Default 1000ms 256MiB

Maximum Orders Delivered

Maximum Orders Delivered

You are given a fleet of delivery drones and a list of orders. Each drone has a maximum distance it can cover, and each order is located at a certain distance. A drone can deliver an order if its maximum distance is greater than or equal to the order's destination distance. Note that each drone can deliver at most one order. Your task is to determine the maximum number of orders that can be delivered under these constraints.

Formally, let (a_i) be the maximum distance of the (i)-th drone and (b_j) be the distance to the (j)-th order. A drone can deliver an order if (a_i \geq b_j). The goal is to maximize the number of pairings between drones and orders such that each drone is used at most once and each order is delivered at most once.

Constraints:

  • (1 \leq d, o \leq 10^5), where (d) is the number of drones and (o) is the number of orders.
  • (1 \leq a_i, b_j \leq 10^9).

inputFormat

The input is read from standard input (stdin) and consists of three lines:

  1. The first line contains two space-separated integers, (d) and (o), representing the number of drones and the number of orders, respectively.
  2. The second line contains (d) space-separated integers representing the maximum distances (capacities) of the drones.
  3. The third line contains (o) space-separated integers representing the distances to the order destinations.

outputFormat

Output a single integer to standard output (stdout), which is the maximum number of orders that can be delivered.## sample

3 4
5 7 8
4 6 8 10
3