#K72967. Task Assignment Problem

    ID: 33871 Type: Default 1000ms 256MiB

Task Assignment Problem

Task Assignment Problem

In this problem, you are given (T) tasks and (M) team members. Each task requires a certain amount of time and each team member has a limited availability. Your task is to determine whether it is possible to assign all tasks to the team members such that the total time assigned to any team member does not exceed his/her available time.

Formally, let the tasks take times (a_1, a_2, \dots, a_T) and the available times of the team members be (b_1, b_2, \dots, b_M). You need to check if there is a way to assign tasks to team members so that for each task (a_i), it is assigned to some team member (j) and the summed times of tasks assigned to team member (j) do not exceed (b_j).

Print YES if such an assignment exists, otherwise print NO.

inputFormat

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

The first line contains two integers (T) and (M) separated by a space, where (T) is the number of tasks and (M) is the number of team members.

The second line contains (T) space-separated integers representing the time required for each task.

The third line contains (M) space-separated integers representing the available time for each team member.

outputFormat

Output a single line to standard output (stdout) containing either YES if it is possible to assign all tasks without exceeding any team member's available time, or NO otherwise.## sample

5 3
2 3 4 5 6
10 8 7
YES