The sum of the last diagonal X29958


Statement
 

pdf   zip

html

Write a program to find the sum of the last diagonal of the matrix. Given matrix M with R rows and C columns. Its last diagonal always contains element MR,C

Input

The first line provides two numbers: R and C the number of rows and columns in the matrix respectively. 0 ≤ R,C ≤ 1000. Next R lines with C integer numbers follows. All the absolute values of the matrix are less than or equal to 109.

Output

Print one integer number - the sum of the last diagonal.

Public test cases
  • Input

    2 2
    1 3
    3 1
    

    Output

    2
    
  • Input

    1 2
    1 2
    

    Output

    2
    
  • Input

    3 2
    2 4
    4 6
    1 1
    

    Output

    5
    
  • Information
    Author
    Dmitry Bufistov
    Language
    English
    Translator
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++ Python
    User solutions