algorithm - Finding the maximum sum from a matrix -
there matrix m rows , n columns. task find maximum sum choosing single element each row , column. came solution, finds maximum whole matrix , sets row , column 0 adds sum , proceeds finding next max. repeats m times.
but problem approach if there repetitive elements. i'll try explain example. here matrix..
3 6 5 3
9 4 9 2
8 1 4 3
4 7 2 5
now, if follow above method.. sum 9 + 7 + 5 + 3 whereas should 9 + 8 + 7 + 3. how solve problem.. i'm stuck
update: columns cost of seats can assigned person , rows number of persons. want assign them in such way, max cost.
isn't http://en.wikipedia.org/wiki/assignment_problem, typically solved http://en.wikipedia.org/wiki/hungarian_algorithm? obviously, want maximum rather minimum, surely can achieve maximising costs -(the real cost) or, if worried -ve costs, (max cost in matrix) - (real cost).
Comments
Post a Comment