#K36527. Gadget Storage in a Warehouse

    ID: 25774 Type: Default 1000ms 256MiB

Gadget Storage in a Warehouse

Gadget Storage in a Warehouse

You are given a warehouse represented as a grid with M rows and N columns. Each cell in the grid has a certain storage capacity. You are also given a total number of gadgets G that need to be stored. Determine whether it is possible to store all the gadgets in the warehouse by verifying if the total capacity of the grid is at least G.

Mathematically, let \(C_{ij}\) be the capacity of the cell in the i-th row and j-th column. You need to check if

\[ \sum_{i=1}^{M}\sum_{j=1}^{N} C_{ij} \geq G \]

If the inequality holds, output YES; otherwise, output NO.

inputFormat

The first line of input contains three space-separated integers: G, M, and N, where:

  • G is the total number of gadgets to store.
  • M is the number of rows in the warehouse grid.
  • N is the number of columns in the warehouse grid.

This is followed by M lines, each containing N space-separated integers representing the capacity of each section in that row.

outputFormat

Output a single line containing YES if all gadgets can be stored in the warehouse, or NO otherwise.

## sample
100 3 3
10 20 30
10 5 5
10 5 5
YES