#P9756. Chair Arrangement Feasibility

    ID: 22902 Type: Default 1000ms 256MiB

Chair Arrangement Feasibility

Chair Arrangement Feasibility

Domagoj has placed (n) tables in a room. Now chairs need to be added. There are (m) colors available, and for the (i)-th color there are (a_i) chairs. Each team consists of exactly 4 members. Hence, exactly 4 chairs must be placed around each table. In addition, the following conditions must be satisfied:

  1. All chairs at a single table must be of the same color.
  2. Every available color (from the (m) colors) must be used at least once.

Formally, let each table be assigned a color. For each color (i), let (t_i) denote the number of tables that use that color. The requirements are:

  • (t_i \ge 1) for all (i = 1,2,\ldots,m) (each color is used at least once),
  • (\sum_{i=1}^{m} t_i = n) (every table is assigned a color), and
  • (4 \times t_i \le a_i) for every (i) (available chairs of color (i) suffice).

Determine whether there exists an assignment of colors to tables that satisfies these conditions.

It is guaranteed that all input values are integers. If such an arrangement exists, output "Yes"; otherwise, output "No".

inputFormat

The input is given in two lines:

  • The first line contains two integers (n) and (m) separated by a space, representing the number of tables and the number of chair colors, respectively.
  • The second line contains (m) integers (a_1, a_2, \ldots, a_m) separated by spaces, where (a_i) is the number of chairs available of the (i)-th color.

outputFormat

Output a single line containing "Yes" if it is possible to arrange the chairs under the given conditions, or "No" if it is not possible.

sample

5 3
4 8 5
No