The sum of the last diagonal

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 M_(R, 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 10⁹.

Output

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

Problem information

Author: Unknown

Generation: 2026-01-25T15:00:05.517Z

© Jutge.org, 2006–2026.
https://jutge.org
