Partitioning a matrix with non-guillotine cuts to minimize the maximum cost