#C8905. Maximum Task Assignment

    ID: 52939 Type: Default 1000ms 256MiB

Maximum Task Assignment

Maximum Task Assignment

You are given two arrays: one represents the effort required for a set of tasks, and the other represents the capacity of a set of workers. Each task requires a certain effort, and a worker can complete a task only if the worker's capacity is at least as high as the task's effort.

The goal is to assign tasks to workers such that each task is assigned to at most one worker and each worker can complete at most one task. The assignment is valid only if for a task with required effort t and a worker with capacity w, the condition \[ w \ge t \] holds. Your task is to determine the maximum number of tasks that can be completed.

Example: For tasks = [3, 2, 1] and workers = [4, 3, 1, 2], an optimal assignment completes 3 tasks.

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  1. A single integer n representing the number of tasks.
  2. n space-separated integers representing the effort required for each task.
  3. A single integer m representing the number of workers.
  4. m space-separated integers representing the maximum effort each worker can handle.

outputFormat

Output to standard output (stdout) a single integer: the maximum number of tasks that can be completed.

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