#P9756. [COCI 2022/2023 #3] Estimathon

[COCI 2022/2023 #3] Estimathon

Background

Paula and Domagoj are about to organize an exciting team competition called Estimathon. They have already prepared the problems, and are now arranging the room for it.

Problem Description

In the blink of an eye, Domagoj has placed nn tables in the room. Now they need to add chairs. They have chairs of various colors. There are mm colors in total, and the number of chairs of the ii-th color is aia_i. Each team consists of four people. Therefore, for each table, Paula and Domagoj need to add 44 chairs. They want to arrange the room as nicely as possible. To do so, they set the following requirements:

  • The chairs at each table must all be the same color.
  • Each color of chairs must be used by at least one table.

Because they care too much about the room being perfect, they suddenly realize that the contest has already begun. Please help them determine whether there exists a possible arrangement.

Input Format

The first line contains two integers n,mn, m, representing the number of tables and the number of chair colors.

The second line contains mm integers aia_i, where the ii-th number represents the number of chairs of the ii-th color.

Output Format

Output one string in a single line.

If there exists an arrangement that satisfies the requirements, output DA;

otherwise output NE.

7 3
5 21 9
DA
5 4
8 5 10 3
NE
6 5
5 5 5 5 5
NE

Hint

Sample Explanation #2.

We can make 55 tables each with chairs of the same color, but we cannot make any table use the fourth color, so the second requirement cannot be satisfied.

Constraints.

Subtask\text{Subtask} Points Special Properties
11 1111 a1=...=am=4a_1=... =a_m=4
22 3939 No special restrictions

For 100%100\% of the testdata, 1n,m1001\leq n, m \leq 100 and 1ai1001\le a_i\le 100.

This problem is worth 5050 points.

Translated by ChatGPT 5