Hey, I saw the editorial and understood the solution . But I used Greedy-Approach to solve the problem . Can anyone give me a testcase on which my solution is failing. (Try to avoid 0 based testcases as I am making some very obvious conceptual flaw.)
I sorted the blocks and start inserting them in stack .
Loop on all elements in decreasing order
a new block adds up to already existing value in stack and makes it closer to EACH value i simply increament that value.
after incrementing it becomes equal to EACH value I pop the entry.
i add it as a seprate entry in stack.
If stack empty ans = “YES” else “NO”.
EACH = value of each group.