Easy25 pts
Fair Rations
N people with B[i] loaves. Each operation gives 1 loaf to person i and 1 to neighbor (i-1 or i+1). Find minimum loaves to make all counts even, or return 'NO'. Example: B=[2,3,4,5,6] → Person 1 has 3 (odd) → Give to person 1 and 2: [2,4,4,5,6] → Person 3 has 5 (odd) → Give to person 3 and 4: [2,4,4,6,6] → All even. Total: 4 loaves distributed.
Input
First line: N. Second line: N space-separated integers (initial loaves).
Output
The minimum number of loaves (as string) or 'NO'.
Sample
5 2 3 4 5 6
Expected
4
Loading editor…
Output
No output yet. Run your code to see results.