C#求问只有最后一个checkpoint出现RE是啥情况
查看原帖
C#求问只有最后一个checkpoint出现RE是啥情况
855093
0x00AC3375楼主2024/9/12 19:27

虽然我知道洛谷应该很少有(如果有)人使用C#

↓↓↓ 90分的代码 ↓↓↓

using System;
using static System.Math;
class P1005
{
    public static decimal[,] matrix = new decimal[84, 84];
    public static decimal[,] score = new decimal[84, 84];
    public static int n, m;

    public static decimal Solve(decimal[] line)
    {
        decimal[,] inner = new decimal[84, 84];
        for (int t = 0; t <= m; t++)
        {
            for (int i = 1; i + t <= m; i++)
            {
                inner[i, i + t] = Max(2 * inner[i + 1, i + t] + 2 * line[i], 2 * inner[i, i + t - 1] + 2 * line[i + t]);
            }
        }
        return inner[1, m];
    }

    public static decimal highscore = 0;

    public static void Main()
    {
        string[] nm = Console.ReadLine().Split();
        n = Convert.ToInt32(nm[0]);
        m = Convert.ToInt32(nm[1]);
        for (int i = 1; i <= n; i++)
        {
            string[] current_line = Console.ReadLine().Split();
            for (int j = 1; j <= m; j++)
            {
                matrix[i, j] = Convert.ToDecimal(current_line[j - 1]);
            }
        }
        for (int i = 1; i <= n; i++)
        {
            decimal[] current_line = new decimal[m + 10];
            for (int j = 1; j <= m; ++j) current_line[j] = matrix[i, j];
            highscore += Solve(current_line);
        }
        Console.Write(highscore);
    }
}
2024/9/12 19:27
加载中...