#C2203. Maximum Number of Jobs Processed

    ID: 45494 Type: Default 1000ms 256MiB

Maximum Number of Jobs Processed

Maximum Number of Jobs Processed

You are given a list of server capacities and a list of job resource requirements. A server can process a job if its capacity is greater than or equal to the job's requirement. Each server can process at most one job. Your task is to determine the maximum number of jobs that can be processed by assigning jobs to appropriate servers.

Approach: One effective strategy is to sort both the server capacities and job requirements. Then, using a two-pointer technique, match a job with the smallest available server that can process it. Formally, if we denote the sorted server capacities by \(S\) and job requirements by \(J\), the condition for a valid assignment is:

[ S[i] \ge J[j] ]

By iterating through both lists, you can count the maximum number of jobs that can be processed.

inputFormat

The input is given in three lines:

  1. The first line contains two integers \(n\) and \(m\), where \(n\) is the number of servers and \(m\) is the number of jobs.
  2. The second line contains \(n\) space-separated integers representing the capacities of the servers.
  3. The third line contains \(m\) space-separated integers representing the resource requirements of the jobs.

outputFormat

Output a single integer indicating the maximum number of jobs that can be successfully processed.

## sample
3 3
10 20 30
10 10 30
3