#K94742. Maximum Participant Allocation

    ID: 38709 Type: Default 1000ms 256MiB

Maximum Participant Allocation

Maximum Participant Allocation

Given m participants and n questions, where each participant has an associated skill level and each question has a difficulty level, determine the maximum number of participants that can be allocated to a question. A participant can only be allocated to a question if his or her skill level is greater than or equal to the difficulty level of the question. Each participant can be assigned to at most one question and each question can be allocated to at most one participant.

The problem can be solved using a greedy algorithm: sort the list of skill levels and the list of difficulty levels. Then, match the lowest skill level that meets the difficulty requirement with the corresponding question. In mathematical terms, given arrays \( S = [s_1, s_2, \dots, s_m] \) and \( D = [d_1, d_2, \dots, d_n] \) (sorted in non-decreasing order), find the maximum number of pairs \( (s_i, d_j) \) such that \( s_i \ge d_j \).

inputFormat

The input is given through standard input (stdin) in the following format:

  1. The first line contains two space-separated integers m and n, representing the number of participants and the number of questions respectively.
  2. The second line contains m space-separated integers, representing the skill levels of the participants.
  3. The third line contains n space-separated integers, representing the difficulty levels of the questions.

outputFormat

Output a single integer to standard output (stdout) which is the maximum number of participants that can be allocated to the questions according to the specified rules.

## sample
5 3
4 3 2 5 1
2 3 4
3