{"problem":{"name":"Souvenirs","description":{"content":"Sigma and his brother Sugim are in the $H \\\\times W$ grid. They wants to buy some souvenirs.   Their start position is upper-left cell, and the goal position is lower-right cell.   Some cells has a so","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"s8pc_3_d"},"statements":[{"statement_type":"Markdown","content":"Sigma and his brother Sugim are in the $H \\\\times W$ grid. They wants to buy some souvenirs.  \nTheir start position is upper-left cell, and the goal position is lower-right cell.  \nSome cells has a souvenir shop. At $i$-th row and $j$-th column, there is $a_{i, j}$ souvenirs.  \nIn one move, they can go left, right, down, and up cell.  \nBut they have little time, so they can move only $H+W-2$ times.  \nThey wanted to buy souvenirs as many as possible, but they had no computer, so they couldn't get the maximal numbers of souvenirs.  \nWrite a program and calculate the maximum souvenirs they can get, and help them.\n\n## Input\n\nThe input is given from standard input in the following format.  \n\n> $H \\\\ W$ $a_{1, 1} \\\\ a_{1, 2} \\\\ \\\\cdots \\\\ a_{1, W}$ $a_{2, 1} \\\\ a_{2, 2} \\\\ \\\\cdots \\\\ a_{2, W}$ $\\\\vdots \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\vdots \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\vdots$ $a_{H, 1} \\\\ a_{H, 2} \\\\ \\\\cdots \\\\ a_{H, W}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"s8pc_3_d","tags":[],"sample_group":[["3 3\n1 0 5\n2 2 3\n4 2 4","21\n\nThe cell at $i$-th row and $j$-th column is denoted $(i, j)$.  \nIn this case, one of the optimal solution is this:  \n\n*   Sigma moves $(1, 1) -> (1, 2) -> (1, 3) -> (2, 3) -> (3, 3)$.\n*   Sugim moves $(1, 1) -> (2, 1) -> (3, 1) -> (3, 2) -> (3, 3)$.\n\nThen, they can get $21$ souvernirs."],["6 6\n1 2 3 4 5 6\n8 6 9 1 2 0\n3 1 4 1 5 9\n2 6 5 3 5 8\n1 4 1 4 2 1\n2 7 1 8 2 8","97"]],"created_at":"2026-03-03 11:01:14"}}