Are the power strips enough?
InterviewTime limit1sMemory limit512 MB
Given K power strips with 3 to 8 sockets each, each strip can power at most half its sockets since adjacent sockets cannot both be used; decide if the total reaches N.
- Level
Easy3 of 10
- Topics
- Greedy, Math, Implementation
- Solved
- No attempts yet
Problem
Today the study group meets, and the place has changed from an Inha University lecture room to the NAVER D2 campus, so Junho, who is in charge of the power strips, has to lay them out before the session starts. The group owns more power strips than the members need, in sizes from 3 sockets up to 8 sockets. Everyone brings only a laptop, so each person uses exactly one socket.
The group has a rule: on one power strip, two neighboring sockets must never be in use at the same time. Junho packed power strips so that everyone could plug in. He is not good at arithmetic, so sometimes he brings too few. Decide whether the strips he brought let everyone connect a laptop.

There are wall outlets, and each power strip draws power from its own outlet. A power strip is never plugged into another power strip.
Input
The first line contains the number of students () and the number of power strips ().
The second line contains the socket counts () of the power strips, in order.
Output
Print YES if every person can plug in, and NO otherwise.