Fácil25 pts
Fair Rations
Traducción al español en progresoEl contenido detallado de esta lección aún se está traduciendo. Mientras tanto, se muestra en inglés.
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.
Entrada
First line: N. Second line: N space-separated integers (initial loaves).
Salida
The minimum number of loaves (as string) or 'NO'.
Ejemplo
5 2 3 4 5 6
Esperado
4
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.