atcoder#ARC090A. [ABC087C] Candies
[ABC087C] Candies
Score : points
Problem Statement
We have a grid. We will denote the square at the -th row and -th column (, ) as .
You are initially in the top-left square, . You will travel to the bottom-right square, , by repeatedly moving right or down.
The square contains candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them.
At most how many candies can you collect when you choose the best way to travel?
Constraints
- (, )
Input
Input is given from Standard Input in the following format:
Output
Print the maximum number of candies that can be collected.
5
3 2 2 4 1
1 2 2 2 1
14
The number of collected candies will be maximized when you:
- move right three times, then move down once, then move right once.
4
1 1 1 1
1 1 1 1
5
You will always collect the same number of candies, regardless of how you travel.
7
3 3 4 5 4 5 3
5 3 4 4 2 3 2
29
1
2
3
5