結果

問題 No.971 いたずらっ子
ユーザー rin204rin204
提出日時 2022-07-05 21:03:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 109,824 KB
最終ジャッジ日時 2024-04-25 02:19:05
合計ジャッジ時間 3,816 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 255 ms
109,824 KB
testcase_01 AC 254 ms
109,696 KB
testcase_02 AC 206 ms
93,184 KB
testcase_03 AC 190 ms
109,440 KB
testcase_04 AC 185 ms
109,696 KB
testcase_05 AC 176 ms
109,312 KB
testcase_06 AC 148 ms
92,160 KB
testcase_07 AC 58 ms
63,232 KB
testcase_08 AC 97 ms
83,072 KB
testcase_09 AC 99 ms
83,968 KB
testcase_10 AC 49 ms
60,032 KB
testcase_11 AC 39 ms
52,096 KB
testcase_12 AC 41 ms
51,840 KB
testcase_13 AC 44 ms
58,240 KB
testcase_14 AC 75 ms
69,888 KB
testcase_15 AC 46 ms
57,856 KB
testcase_16 AC 44 ms
52,864 KB
testcase_17 AC 40 ms
51,840 KB
testcase_18 AC 39 ms
51,840 KB
testcase_19 AC 39 ms
51,840 KB
testcase_20 AC 39 ms
51,840 KB
testcase_21 AC 41 ms
51,968 KB
testcase_22 AC 41 ms
51,968 KB
testcase_23 AC 39 ms
51,712 KB
testcase_24 AC 41 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
S = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == "k":
            add = i + j + 1
        else:
            add = 1
        if i == j == 0:
            continue
        elif i == 0:
            dp[i][j] = dp[i][j - 1] + add
        elif j == 0:
            dp[i][j] = dp[i - 1][j] + add
        else:
            dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + add

print(dp[-1][-1])
0