Company: amdocs_1april
Difficulty: medium
Bobby owns a paper tape divided into a row of n cells, and finds it far too plain, so he wants to color the cells using m different colors. For aesthetic reasons, the i-th color must be used exactly a[i] times, and among any k consecutive cells, no two may share a color. Help Bobby work out whether such a coloring exists. Return 1 if it does and 0 otherwise. Constraints 1 ≤ n ≤ 2 * 10 5 1 ≤ m ≤ 10 5 1 ≤ k ≤ n a.length == m 1 ≤ a[i] ≤ 2 * 10 5 Example: n = 12 m = 6 k = 2 a = 2,2,2,2,2,2 One valid coloring is (1,2,1,2,3,4,3,4,5,6,5,6). Checking any 2 consecutive cells in this arrangement, their colors always differ.