結果

問題 No.971 いたずらっ子
ユーザー KodaiKodai
提出日時 2020-04-27 13:12:09
言語 PyPy3
(7.3.15)
結果
OLE  
実行時間 -
コード長 702 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 276,480 KB
最終ジャッジ日時 2024-05-01 10:00:25
合計ジャッジ時間 11,146 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 OLE -
testcase_01 OLE -
testcase_02 OLE -
testcase_03 OLE -
testcase_04 OLE -
testcase_05 OLE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = list(map(int, input().split()))
a_list = [[s for s in input()] for i in range(H)]

dp_list = [[0 for i in range(W)] for j in range(H)]

for h in range(H):
    for w in range(W):
        if h > 0 and w > 0:
            dp_list[h][w] = min([dp_list[h - 1][w], dp_list[h][w - 1]])
            dp_list[h][w] += (1 + h + w) if a_list[h][w] == "k" else 1
        elif h > 0:
            dp_list[h][w] = dp_list[h - 1][w]
            dp_list[h][w] += (1 + h + w) if a_list[h][w] == "k" else 1
        elif w > 0:
            dp_list[h][w] = dp_list[h][w - 1]
            dp_list[h][w] += (1 + h + w) if a_list[h][w] == "k" else 1
        else:
            continue
print(dp_list)
print(dp_list[-1][-1])
0