#C1839. Water Demand Fulfillment

    ID: 45088 Type: Default 1000ms 256MiB

Water Demand Fulfillment

Water Demand Fulfillment

You are given N houses and M water distribution centers. Each house has a specific water demand and each distribution center has a certain supply capacity. Your task is to determine whether it is possible to satisfy the water demands of all the houses by assigning, in a one-to-one manner, distribution centers to houses.

Note: A distribution center can be used for at most one house. To maximize the chance of meeting the demands, consider pairing the house with the highest water demand with the distribution center offering the highest available capacity, the second highest with the second highest, and so on.

Formally, let \(d_1, d_2, \ldots, d_N\) be the water demands of the houses and \(s_1, s_2, \ldots, s_M\) be the supply capacities of the distribution centers. If after sorting both sequences in descending order we have \(d_i \le s_i\) for all \(1 \le i \le N\) (and \(M \ge N\)), then output "Yes"; otherwise, output "No".

inputFormat

The input will be provided in the following format:

N M
water_demand_1 water_demand_2 ... water_demand_N
supply_capacity_1 supply_capacity_2 ... supply_capacity_M

Where:

  • N is the number of houses.
  • M is the number of distribution centers.
  • The second line contains N space-separated integers representing the water demand of each house.
  • The third line contains M space-separated integers representing the supply capacity of each distribution center.

outputFormat

Output a single line containing either "Yes" if all house water demands can be met, or "No" otherwise.

## sample
3 3
10 20 30
30 20 10
Yes