#C1683. Maximize Delivery Requests
Maximize Delivery Requests
Maximize Delivery Requests
Given ( m ) trucks and ( n ) delivery requests, each truck has a certain capacity and each delivery request requires transporting a specified amount of goods. A delivery request can be fulfilled by a truck if the truck's capacity is at least the amount required by the request. Each truck can fulfill at most one delivery request. Your task is to determine the maximum number of delivery requests that can be fulfilled.
Formally, let the truck capacities be ( T = {t_1, t_2, \ldots, t_m} ) and the delivery requests be ( R = {r_1, r_2, \ldots, r_n} ). A truck ( t_i ) can serve a request ( r_j ) if and only if ( t_i \ge r_j ). Find the maximum matching between trucks and requests under this constraint.
inputFormat
The input is read from standard input and consists of three lines:
1. The first line contains two integers ( m ) and ( n ) separated by a space, representing the number of trucks and the number of delivery requests respectively.
2. The second line contains ( m ) integers representing the capacities of the trucks. If ( m = 0 ), this line will be empty.
3. The third line contains ( n ) integers representing the delivery requests. If ( n = 0 ), this line will be empty.
outputFormat
Output a single integer to standard output, which is the maximum number of delivery requests that can be fulfilled.## sample
3 4
4 5 6
2 3 5 7
3