Selecting maximum element from previoulsy selected element
Sum = prev NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT max_smaller = - 10 ** 9 NEW_LINE for j in range ( M - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( a [ i ] [ j ] < prev and a [ i ] [ j ] > max_smaller ) : NEW_LINE INDENT max_smaller = a [ i ] [ j ] NEW_LINE DEDENT DEDENT DEDENT