Problems > Anti-Diagonal Sums

Anti-Diagonal Sums

Difficulty: 1100 2000 ms 128 MB

implementation

Print the sums of the N+M−1 anti-diagonals (cells sharing i+j), from the top-left corner outward.

Input: the first line has N and M; the next N lines each have M integers.

Output: N+M−1 sums.

Constraints:

  • 1 ≤ N, M ≤ 100

Sample Tests

Input 1
2 2
1 2
3 4
Output 1
1 5 4
Input 2
1 3
5 6 7
Output 2
5 6 7

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.