#K88192. Cake Preparation
Cake Preparation
Cake Preparation
You are given the number of cakes n and the number of ingredients m. For each cake, a list of ingredient requirements is provided in a matrix of size n × m. Additionally, you are given a list of available quantities for each of the m ingredients. Your task is to determine whether it is possible to prepare all the cakes with the available ingredients.
For each ingredient j (where 1 ≤ j ≤ m), if the quantity required from all cakes is denoted by \(\sum_{i=1}^{n} a_{ij}\) and the available quantity in the pantry is \(b_j\), then the cakes can be prepared if and only if:
[ \sum_{i=1}^{n} a_{ij} \le b_j \quad \text{for every } j = 1,2,\ldots,m. ]
Output YES if it is possible to prepare all the cakes; otherwise, output NO.
inputFormat
The first line of input contains two integers n and m, representing the number of cakes and the number of ingredients respectively. The following n lines each contain m integers representing the quantities of each ingredient required for that cake. The last line contains m integers representing the available quantities of each ingredient in the pantry.
outputFormat
Output a single line with either "YES" if all cakes can be prepared with the given ingredients, or "NO" otherwise.## sample
2 3
2 0 1
1 2 2
3 2 3
YES