#K65867. Pyramid Construction Challenge

    ID: 32293 Type: Default 1000ms 256MiB

Pyramid Construction Challenge

Pyramid Construction Challenge

Given a pyramid of height \(h\) with the base row consisting entirely of ones, determine whether it is possible to construct the pyramid under the following rule:

For each level (starting from the base), each element in the next level is the sum of two adjacent numbers from the current level. Every computed sum must be present in the available set of block numbers. The process is repeated until the pyramid reduces to a single number at the top level. If all the sums at every level are available in the given set, the pyramid can be built; otherwise, it cannot.

For example, when \(h = 2\) with the base row [1, 1], the only sum computed is 2. If 2 is among the given block numbers, the pyramid construction is successful, and the answer should be YES; otherwise, it should be NO.

inputFormat

The first line contains two integers \(h\) and \(n\), where \(h\) is the height of the pyramid and \(n\) is the number of available block numbers.

The second line contains \(n\) space-separated integers representing the available block numbers.

outputFormat

Output a single line containing YES if the pyramid can be built following the given rules, or NO otherwise.

## sample
2 3
1 2 3
YES