All problems

Problem 991

Richest Customer Wealth

Easy · 10 pts · Matrix, Array

Problem

Each row of the matrix lists how much money one customer has in each bank, one column per bank. A customer's wealth is the total of their row. Print the wealth of the richest customer. Sum every row and take the maximum; this is a good first exercise on nested loops over a two-dimensional array.

Input

The first line contains R and C. Each of the next R lines contains C integers.

Output

Print the largest row sum.

Constraints

1 <= R, C <= 50; 1 <= value <= 100

Example input

2 3
1 2 3
3 2 1

Example output

6

Explanation

For 1 2 3 / 3 2 1, both customers have 6 in total, so the richest wealth is 6.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Cells with Odd Values in a Matrix Next: Determine Whether Matrix Can Be Obtained By Rotation