9 人解决,23 人已尝试。
12 份提交通过,共有 114 份提交。
7.6 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
John is (as you probably know) a marble collector. He keeps his marbles in boxes. He also likes to keep things in order - in each box there are only marbles of the same color (some boxes may be empty).
One day, his younger brother was playing with the marbles. After he was done, he put all the marbles back in boxes, but he did it randomly, so certain boxes might now contain marbles of different colors. You are given some boxes, where each element is a space separated list of integers and the j-th integer of the i-th element is the number of marbles of color j in the i-th box. John wants him to regroup the marbles so that each box is either empty or contains only marbles of the same color, and all marbles of the same color are in the same box.
There are several test cases,each test case begins whih two integers N(1<=N<=50) and M(1<=M<=14),means there are N boxes and M colors of marbles.The next N lines,each contains M integers.Each integer in boxes will not contain leading zeros and will be between 0 and 99, inclusive.There is a blank line between each test case.
For each test case,output the minimal number of moves necessary to do what John wants, where each move consists of taking exactly one marble from any box and putting it into another.
2 2 77 97 8 0 3 3 6 97 7 73 45 0 67 45 63
77 170 Hint Case 1: Move all marbles of color 0 to box 1. Case 2: In the end, all marbles of color 0 are in box 1, all marbles of color 1 are in box 0, and all marbles of color 2 are in box 2.
9 人解决,23 人已尝试。
12 份提交通过,共有 114 份提交。
7.6 EMB 奖励。
创建: 16 年,8 月前.
修改: 7 年,3 月前.
最后提交: 4 年前.
来源: N/A