結果

問題 No.2064 Smallest Sequence on Grid
ユーザー ああいいああいい
提出日時 2022-09-04 10:57:35
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 503 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 848,724 KB
最終ジャッジ日時 2024-04-29 10:14:02
合計ジャッジ時間 7,692 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,840 KB
testcase_01 AC 36 ms
51,968 KB
testcase_02 AC 38 ms
51,584 KB
testcase_03 AC 37 ms
51,840 KB
testcase_04 AC 36 ms
51,456 KB
testcase_05 AC 37 ms
52,096 KB
testcase_06 AC 38 ms
52,224 KB
testcase_07 AC 39 ms
51,584 KB
testcase_08 AC 45 ms
59,392 KB
testcase_09 AC 45 ms
59,648 KB
testcase_10 AC 55 ms
62,336 KB
testcase_11 AC 55 ms
61,952 KB
testcase_12 AC 48 ms
61,440 KB
testcase_13 AC 48 ms
62,336 KB
testcase_14 AC 47 ms
63,104 KB
testcase_15 AC 45 ms
61,568 KB
testcase_16 AC 45 ms
62,208 KB
testcase_17 MLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
S = [input() for _ in range(H)]

dp = [[None] * W for _ in range(H)]
dp[0][0] = S[0][0]
for h in range(H):
    for w in range(W):
        if h == 0 and w == 0:continue
        t = None
        s = None
        if h > 0:
            t = dp[h-1][w] + S[h][w]
        if w > 0:
            s = dp[h][w-1] + S[h][w]
        if t is None:
            dp[h][w] = s
        elif s is None:
            dp[h][w] = t
        else:
            dp[h][w] = min(t,s)
print(dp[-1][-1])
0