#C6384. Task Assignment Problem

    ID: 50138 Type: Default 1000ms 256MiB

Task Assignment Problem

Task Assignment Problem

You are given a set of tasks and a set of drivers. Each task takes a certain amount of time and each driver has a maximum working time available. Your goal is to determine whether it is possible to assign all tasks to the drivers such that no driver is assigned work time exceeding their available capacity.

The tasks and drivers are given as lists of positive integers. The optimal strategy is to assign the longest tasks first to the drivers with the highest available working time. If a task cannot be assigned to any driver, then the assignment is impossible.

Task: Given the number of tasks n, the number of drivers m, a list of task durations, and a list of driver capacities, determine if it is possible to assign all tasks to drivers without exceeding any driver's capacity.

Use a greedy approach to ensure that tasks are assigned efficiently.

inputFormat

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

  1. The first line contains two integers n and m separated by a space, where n is the number of tasks and m is the number of drivers.
  2. The second line contains n space-separated integers representing the durations of each task.
  3. The third line contains m space-separated integers representing the maximum working time (capacity) for each driver.

outputFormat

Output a single line to standard output (stdout) containing "YES" if it is possible to assign all tasks under the given constraints, or "NO" otherwise.## sample

4 3
2 3 5 7
10 7 8
YES