#C10634. Distributing Orders Among Warehouses
Distributing Orders Among Warehouses
Distributing Orders Among Warehouses
You are given n warehouses, each with a certain capacity, and m orders that need to be allocated among these warehouses. The task is to determine if it is possible to distribute all the orders without exceeding the capacity of any warehouse.
Mathematically, let the capacities be \(c_1, c_2, \dots, c_n\). If the condition
\[
\sum_{i=1}^{n} c_i \ge m
\]
holds, then all orders can be distributed (output YES
), otherwise they cannot (output NO
).
inputFormat
The input is read from standard input and begins with an integer T
representing the number of test cases. Each test case consists of two parts:
- The first line contains two integers
n
andm
, wheren
is the number of warehouses andm
is the number of orders. - The second line contains
n
space-separated integers representing the capacities of the warehouses.
outputFormat
For each test case, output a single line containing YES
if the orders can be distributed without exceeding the capacities, or NO
otherwise.
1
3 10
5 8 2
YES
</p>