report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Maximum path 3 - MarisaOJ: Marisa Online Judge

Maximum path 3

Time limit: 1000 ms
Memory limit: 256 MB
The forest is in the form of an $n \times n$ grid. The cell at row $i$ and column $j$, or cell $(i, j)$, contains $A_{i, j}$ mushrooms. Marisa's journey starts from $(1, 1)$, goes to $(n, n)$, and then returns to $(1, 1)$. On the way from $(1, 1)$ to $(n, n)$, Marisa can move to cell $(i + 1, j)$ or $(i, j + 1)$. On the way back from $(n, n)$ to $(1, 1)$, Marisa can move to cell $(i - 1, j)$ or $(i, j - 1)$. What is the maximum number of mushrooms Marisa can collect? Of course, mushrooms cannot be collected more than once in the same cell. ### Input - The first line contains the integer $n$. - The next $n$ lines each contain $n$ integers representing the grid. ### Output - A single integer representing the maximum number of mushrooms Marisa can collect. ### Constraints - $1 \le n \le 50$ - $0 \le A_{i, j} \le 1000$. ### Example Input: ``` 4 1 0 0 4 0 0 6 0 0 0 0 0 5 0 0 0 ``` Output: ``` 12 ```
Introduction to Dynamic Programming (Part two)
Sake game
Coins
Coins 2
Game on array
Longest increasing subsequence 2
Convolution
Regular bracket sequence
Faulty addition
Weird bank
Delete operation
Palindromize
Color ribbon
Unique subsequences
Unique subsequences 2
Cow exhibition
Knapsack 3
Compressing array
Regular bracket sequence 2
Maximum path 3
Concating substring
Soil
Stacking boxes
String transformation
Palindromic quadruple
Finding teammates
Topic
Dynamic Programming
Rating 1600
Solution (1) Solution