Hamilton - The Musical

아직 제출이 없습니다시간 제한0.1초메모리 제한1024 MB

문제

Nlogonia is well known for its robust road infrastructure. The country has NN cities numbered from 11 to NN, and for each pair of distinct cities ii and jj, there is a two-way road between them with length L_i,jL\_{i,j}.

The citizens of Nlogonia are very excited because the musical Hamilton has arrived in the country for the first time. The organization of Hamilton wants to let every citizen have an opportunity to watch the musical, so they want to choose a path that visits each city exactly PP once. Such a path is a permutation P_1,P_2,,P_NP\_1, P\_2, \dots , P\_N of the NN cities, and its total length is _i=1N1L_P_i,P_i+1\sum\_{i=1}^{N-1}{L\_{P\_i,P\_{i+1}}}.

The organization fears that if they let the actors choose the path, they will have to spend a lot of money on fuel. But they also fear that if they don’t let the actors choose anything, the actors will become demotivated and might have a bad performance on stage. So the organization allowed the actors to choose the cities in the even positions of the path, that is, the actors can choose the cities P_2,P_4,,P_N/2P\_2, P\_4, \dots , P\_{\lfloor N/2 \rfloor }.

After much deliberations, the actors made their choice. Contrary to what one would expect from such a creative bunch, they agreed on a somewhat boring outcome and decided that even positions should be occupied by cities with the same identifier as their indices, that is, P_i=iP\_i = i for even ii.

Now the organization needs your help. Can you determine the minimum total length of a path satisfying the actors’ decision?

입력

The first line contains an integer NN (2N5002 ≤ N ≤ 500) indicating the number of cities in Nlogonia. The next NN lines contain NN integers each, representing the lengths of the roads between cities. The jj-th integer on the ii-th of these lines is L_i,jL\_{i,j} (1L_i,j=L_j,i1091 ≤ L\_{i,j} = L\_{j,i} ≤ 10^9 for i=1,2,,Ni = 1, 2, \dots , N, j=1,2,,Nj = 1, 2, \dots , N and iji \ne j), denoting the length of the two-way road between cities ii and jj. If i=ji = j then L_i,j=0L\_{i,j} = 0, since there is no actual road from a city to itself.

출력

Output a single line with an integer representing the minimum total length of a path that visits each city exactly once satisfying the actors’ decision.