P9756 [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.
Description
In the blink of an eye, Domagoj has placed $n$ tables in the room. Now they need to add chairs. They have chairs of various colors. There are $m$ colors in total, and the number of chairs of the $i$-th color is $a_i$. Each team consists of **four** people. Therefore, for each table, Paula and Domagoj need to add $4$ 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, m$, representing the number of tables and the number of chair colors.
The second line contains $m$ integers $a_i$, where the $i$-th number represents the number of chairs of the $i$-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`.
Explanation/Hint
**Sample Explanation #2.**
We can make $5$ 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.**
|$\text{Subtask}$|Points|Special Properties|
|:-:|:-:|:-:|
|$1$|$11$|$a_1=... =a_m=4$
|$2$|$39$|No special restrictions|
For $100\%$ of the testdata, $1\leq n, m \leq 100$ and $1\le a_i\le 100$.
**This problem is worth $50$ points.**
Translated by ChatGPT 5