結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-04 15:15:31
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,807 bytes
コンパイル時間 7,409 ms
コンパイル使用メモリ 158,584 KB
実行使用メモリ 205,916 KB
最終ジャッジ日時 2024-02-04 15:15:45
合計ジャッジ時間 13,347 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
32,932 KB
testcase_01 AC 83 ms
32,932 KB
testcase_02 AC 83 ms
32,932 KB
testcase_03 AC 81 ms
32,932 KB
testcase_04 AC 81 ms
32,932 KB
testcase_05 AC 81 ms
32,932 KB
testcase_06 AC 80 ms
32,932 KB
testcase_07 AC 125 ms
52,260 KB
testcase_08 AC 147 ms
58,404 KB
testcase_09 AC 147 ms
58,404 KB
testcase_10 WA -
testcase_11 AC 145 ms
58,532 KB
testcase_12 AC 142 ms
61,560 KB
testcase_13 AC 141 ms
61,576 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 82 ms
33,188 KB
testcase_18 AC 85 ms
32,932 KB
testcase_19 WA -
testcase_20 AC 160 ms
61,600 KB
testcase_21 AC 139 ms
56,996 KB
testcase_22 WA -
testcase_23 AC 129 ms
53,412 KB
testcase_24 AC 129 ms
53,284 KB
testcase_25 AC 148 ms
58,532 KB
testcase_26 AC 151 ms
205,916 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (106 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (h, w) = (c[0], c[1]);
        var map = NArr(h);
        var dp = new long[2][][];
        for (var i = 0; i < 2; ++i)
        {
            dp[i] = new long[h][];
            for (var j = 0; j < h; ++j) dp[i][j] = Enumerable.Repeat(long.MinValue, w).ToArray();
        }
        dp[0][0][0] = map[0][0];
        for (var i = 0; i < h; ++i) for (var j = 0; j < w; ++j)
        {
            if (i + 1 < h)
            {
                if (dp[0][i][j] > map[i + 1][j]) dp[0][i + 1][j] = Math.Max(dp[0][i + 1][j], dp[0][i][j] + map[i + 1][j]);
                else dp[1][i + 1][j] = Math.Max(dp[1][i + 1][j], dp[0][i][j]);
                if (dp[1][i][j] > map[i + 1][j]) dp[1][i + 1][j] = Math.Max(dp[1][i + 1][j], dp[1][i][j] + map[i][j]);
            }
            if (j + 1 < w)
            {
                if (dp[0][i][j] > map[i][j]) dp[0][i][j + 1] = Math.Max(dp[0][i][j + 1], dp[0][i][j] + map[i][j + 1]);
                else dp[1][i][j + 1] = Math.Max(dp[1][i][j + 1], dp[0][i][j]);
                if (dp[1][i][j] > map[i][j + 1]) dp[1][i][j + 1] = Math.Max(dp[1][i][j + 1], dp[1][i][j] + map[i][j]);
            }
        }
        WriteLine(Math.Max(Math.Max(dp[0][h - 2][w - 1], dp[0][h - 1][w - 2]), Math.Max(dp[1][h - 2][w - 1], dp[1][h - 1][w - 2])) > map[h - 1][w - 1] ? "Yes" : "No");
    }
}
0