#C2482. Diagonal Dominator Matrix

    ID: 45803 Type: Default 1000ms 256MiB

Diagonal Dominator Matrix

Diagonal Dominator Matrix

You are given an (n \times n) matrix (A) where (1 \le n \le 100) and each element (A_{ij}) is an integer in the range ([-1000,1000]). A matrix is called a diagonal dominator if for every pair of distinct indices (i) and (j) (with (i \neq j)), the following inequality holds:

[ |A_{ii}| + |A_{jj}| \ge \sum_{\substack{k=0 \ k \neq i,j}}^{n-1} \left(|A_{ik}| + |A_{kj}|\right) ]

In other words, the sum of the absolute values of two different diagonal elements must be at least as large as the sum of the absolute values of off-diagonal elements in the respective rows and columns (excluding the positions corresponding to the chosen diagonals). Your task is to determine whether the provided matrix is a diagonal dominator. The answer should be YES if the condition is satisfied for all distinct pairs (i,j), and NO otherwise.

Example:

  • For the matrix:
    2 1
    1 3
        
    We have YES since the condition holds.
  • For the matrix:
    1 2 3
    4 5 6
    7 8 9
        
    The condition fails, so the answer is NO.

inputFormat

The input is given via standard input. The first line contains an integer (n) denoting the size of the matrix. The following (n) lines each contain (n) space-separated integers representing the rows of the matrix.

outputFormat

Print a single line with the string YES if the matrix is a diagonal dominator or NO otherwise.## sample

2
2 1
1 3
YES