int[][] grid = new int[3][]
{
new int[]{1,3,1},
new int[]{1,5,1},
new int[]{4,2,1},
};
var x = grid.Length;
var y = grid[0].Length;
var dp = new int[x][];
for (var i = 0; i < x; i++)
{
for (var j = 0; j < y; j++)
{
dp[i] ??= new int[y];
dp[i][j] = grid[i][j];