Fair Rations
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Caso de ejemplo — tu programa lee de stdin e imprime en stdout.
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.
Formato de entrada
First line: N. Second line: N space-separated integers (initial loaves).
Formato de salida
The minimum number of loaves (as string) or 'NO'.
Restricciones
2 ≤ N ≤ 1000, 1 ≤ B[i] ≤ 10