[C] dp
C []\nint maxCollectedFruits(\n\tint * const * const matrix,\n\tconst int borderLen,\n\tconst int * const _unused\n){\n\tassert(borderLen >= 2);\n\t(void)_unuse
```C []\nint maxCollectedFruits(\n\tint * const * const matrix,\n\tconst int borderLen,\n\tconst int * const _unused\n){\n\tassert(borderLen >= 2);\n\t(void)_unused;\n\n\tint totalCnt = 0;\n\n\tfor (int i = 0; i < borderLen; i += 1){\n\t\ttotalCnt += matrix[i][i];\n\t}\n\n\tint dp[borderLen][borderLen];\n\n\t//leftBottom\n\tdp[borderLen - 1][0] = matrix[borderLen - 1][0];\n\tfor (int col = 1; col < borderLen - 1; col += 1){\n\t\tconst int prevCol = col - 1;\n\t\tfor (int row = borderLen - (1 + col); row < borderLen; row += 1){\n\t\t\tint maxOf3 = 0;\n\t\t\tfor (int offset = -1; offset <= 1; offset += 1){\n\t\t\t\tconst int prevRow = row + offset;\n\t\t\t\tif (!( prevRow >= borderLen - (prevCol + 1) && prevRow < borderLen )){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (dp[prevRow][prevCol] > maxOf3){\n\t\t\t\t\tmaxOf3 = dp[prevRow][prevCol];\n\t\t\t\t}\n\t\t\t}\n\t\t\tdp[row][col] = maxOf3 + matrix[row][col];\n\t\t}\n\t}\n\ttotalCnt += dp[borderLen - 1][borderLen - 2];\n\n\t//rightUp\n\tdp[0][borderLen - 1] = matrix[0][borderLen - 1];\n\tfor (int row = 1; row < borderLen - 1; row += 1){\n\t\tconst int prevRow = row - 1;\n\t\tfor (int col = borderLen - (1 + row); col < borderLen; col += 1){\n\t\t\tint maxOf3 = 0;\n\t\t\tfor (int offset = -1; offset <= 1; offset += 1){\n\t\t\t\tconst int prevCol = col + offset;\n\t\t\t\tif (!( prevCol >= borderLen - (prevRow + 1) && prevCol < borderLen )){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (dp[prevRow][prevCol] > maxOf3){\n\t\t\t\t\tmaxOf3 = dp[prevRow][prevCol];\n\t\t\t\t}\n\t\t\t}\n\t\t\tdp[row][col] = maxOf3 + matrix[row][col];\n\t\t}\n\t}\n\ttotalCnt += dp[borderLen - 2][borderLen - 1];\n\n\treturn totalCnt;\n}\n```
['C']