Math, asked by akashpalvarsu8654, 10 months ago

Maximum sum matrix select one integer from each row such that the sum of these integers is maximum

Answers

Answered by sumitmahey72
1

Answer:

Given a matrix, find the maximum sum we can have by selecting just one element from every row. Condition is element selected from nth row must be strictly greater than element from (n-1)th row, else no element must be taken from row. Print the sum if possible else print -1.

Examples :

Input :

1 2 3

1 2 3

7 8 9

Output : 14 (2 + 3 + 9) (values we

are adding are strictly increasing)

Input :

4 2 3

3 2 1

1 2 2

Output : -1

(No subsequent increasing elements

can be picked from consecutive rows)

Answered by abhishek450
1

please give matrix then I will answer

Similar questions