#C13841. Maximum Sum Assignment in Matrices

    ID: 43424 Type: Default 1000ms 256MiB

Maximum Sum Assignment in Matrices

Maximum Sum Assignment in Matrices

You are given one or more 5x5 matrices. Each matrix consists of 5 lines with 5 space-separated integers. Matrices are separated by one or more blank lines.

For each matrix, you must select exactly one element from each row and each column such that the total sum is maximized. This is equivalent to solving the assignment problem on a 5x5 grid. In mathematical terms, for a given matrix \(A\), you need to compute:

\[ \max_{\sigma \in S_5} \sum_{i=0}^{4} A_{i, \sigma(i)} \]

Your task is to output the total sum of the maximum sums computed for all matrices provided in the input.

inputFormat

The input consists of one or more 5x5 matrices. Each matrix is represented by 5 lines, each containing 5 space-separated integers. Matrices are separated by one or more blank lines.

outputFormat

Output a single integer on a line by itself, representing the sum of the maximum sums for all given matrices.

## sample
7 53 183 439 863
497 383 563 79 973
287 63 343 169 583
627 343 773 959 943
767 473 103 699 303
3315