All submissions for this problem are available.
An exam is to be conducted. N students will give the exam. Students are numbered as 1, 2, 3 . . N. There are M questions and each question should be asked to only one of those N students. The questions are numbered as 1, 2, 3 . . M. The conditions are that:
1. ith question should be asked to exactly Ai students
2. No two consecutively numbered students get the same question to solve.
Given numbers N, M and array Ai, find out if the questions can be assigned to students as per the given conditions.
Note that summation Ai will be equal to N.
First line contains two space seperated integers M and N Second line contains M spaced integers, Ai denoting the times ith question has to be asked
Print "YES" if the questions can be arranged, print "NO" otherwise
1 ≤ M ≤ N ≤ 10^6 0 ≤ Ai ≤ N
Input: 3 7 3 3 1 Output: YES
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
Fetching successful submissions