#C11898. Distribute Weights in Containers

    ID: 41264 Type: Default 1000ms 256MiB

Distribute Weights in Containers

Distribute Weights in Containers

You are given n weights and m containers with specified capacities. The task is to determine whether it is possible to distribute all the weights among the containers such that no container’s total weight exceeds its capacity.

More formally, you are given a list of n weights \(w_1, w_2, \dots, w_n\) and a list of m capacities \(c_1, c_2, \dots, c_m\). You need to check if there exists an assignment of each weight to one container such that for every container, the sum of the weights assigned to it is at most its capacity.

Input/Output: The program should read input from the standard input and write the result to the standard output. The output should be either "YES" if the distribution is possible, or "NO" otherwise.

inputFormat

The first line contains two integers n and m (\(1 \leq n, m \leq 10^5\)), where n is the number of weights and m is the number of containers.

The second line contains n space-separated integers representing the weights.

The third line contains m space-separated integers representing the capacities of the containers.

outputFormat

Output a single line containing either "YES" if it is possible to assign the weights to the containers under the given constraints, or "NO" if it is not possible.

## sample
3 2
10 20 30
40 30
YES