社区讨论
C#求问只有最后一个checkpoint出现RE是啥情况
P1005[NOIP 2007 提高组] 矩阵取数游戏参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @m0z7gqli
- 此快照首次捕获于
- 2024/09/12 19:27 去年
- 此快照最后确认于
- 2025/11/04 21:20 4 个月前
↓↓↓ 90分的代码 ↓↓↓
CSHARPusing 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);
}
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...