On a hot summer day, Bessie the cow feels lazy. She wants to pick a starting cell in her field so that she can reach as much tasty grass as possible within a short walk.
The field is an N×N grid (1≤N≤400). Cell (r,c) (1≤r,c≤N) contains G(r,c) units of grass (0≤G(r,c)≤1000). From her starting cell, Bessie takes at most K steps (0≤K≤2N). Each step moves her one cell north, south, east, or west.
Choose the best starting cell. Output the maximum total grass she can reach within K steps.
Try every starting cell and sum grass reachable within K steps.