TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

You were just hired as CEO of the local junkyard.One of your jobs is dealing with the incoming trash and sorting it for recycling.The trash comes every day in N containers and each of these containers contains certain amount of each of the N types of trash. Given the amount of trash in the containers find the optimal way to sort the trash. Sorting the trash means putting every type of trash in separate container. Each of the given containers has infinite capacity. The effort for moving one unit of trash from container i to j is 1 if i ≠ j otherwise it is 0.You are to minimize the total effort.

Input Format

There are possibly more than one test cases in the input.


The first line of each test case contains the number N (1 ≤ N ≤ 600), the rest of the input contains the descriptions of the containers.The (1 + i)-th line contains the description of the i-th container the j-th amount (0 ≤ amount ≤ 300) on this line denotes the amount of the j-th type of trash in the i-th container.

Output Format

You should write the minimal effort that is required for sorting the trash.

Sample Input 1

4
62 41 86 94
73 58 11 12
69 93 89 88
81 40 69 13
1
100

Sample Output 1

650
0

Hints

TLE, 怪我囉?

Problem Source

Migrated from old NTUJ.

Ural 1076

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 65536 200