AdvancedRating 1600
Falling Path, No Same Column
Choose one number from every row of the n × n grid so that no two neighbouring rows use the same column. Print the smallest possible sum.
Input
n (≥ 2), then n rows.
Output
One integer.
Sample 1
Input
3 1 2 3 4 5 6 7 8 9
Output
13
Sample 2
Input
2 1 1 1 1
Output
2
Output appears here