Estimathon
InterviewTime limit1sMemory limit1024 MB
Given the chair count of each colour, decide whether every colour can fill whole tables of four chairs so that exactly n tables are filled.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Paula and Domagoj are organizing a team competition called Estimathon. They have already prepared the questions and are now arranging the room for the quiz.
Domagoj has already placed tables in the room. Now chairs need to be added. The chairs come in colours, and there are chairs of the -th colour. Every team has four people, so each table needs exactly four chairs. Paula and Domagoj want the room to look as nice as possible, so they agreed on these conditions:
- Each table has all of its chairs in the same colour.
- Every chair colour is used. For every colour, at least one table has chairs of that colour.
The quiz starts soon. Determine whether a chair arrangement that satisfies both conditions is possible.
Input
The first line contains integers and (), the number of tables and the number of chair colours.
The second line contains integers (), where is the number of chairs of the -th colour.
Output
Print one line containing DA if the chairs can be arranged so that both conditions hold. Otherwise, print NE.
Hint
Clarification of the second sample: Five tables can all be filled with chairs of the same colour, but no table can use colour 4, so the second condition cannot be satisfied.