The Matrix

3.5

2 votes
Medium
Problem

Given the n elements of the leading diagonal of n*n matrix. Assuming that all the other elements of the matrix are equal, let’s say x. Find the minimum value of x such that the sum of the leading diagonal element is less than the sum of the other element.
Constraints: 1 <= n <= 25 All the diagonal elements are less than 50.
Input and Output format: First line of input is n. Followed by n numbers in the range 1 to 50. Output the smallest value of x as mentioned in the question.

Time Limit: 0.5
Memory Limit: 256
Source Limit:
Explanation

5 3 3 3
3 10 3 3
3 3 4 3
3 3 3 7


Sum of diagonal elements (26) < sum of all other elements (36)

Editor Image

?