結果

問題 No.971 いたずらっ子
ユーザー yomo3yomo3
提出日時 2020-01-22 04:22:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 109,884 KB
最終ジャッジ日時 2023-08-07 08:03:28
合計ジャッジ時間 5,195 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
109,116 KB
testcase_01 AC 300 ms
109,176 KB
testcase_02 AC 256 ms
104,980 KB
testcase_03 AC 245 ms
108,644 KB
testcase_04 AC 239 ms
109,884 KB
testcase_05 AC 234 ms
108,712 KB
testcase_06 AC 197 ms
91,232 KB
testcase_07 AC 89 ms
76,104 KB
testcase_08 AC 130 ms
82,504 KB
testcase_09 AC 130 ms
83,276 KB
testcase_10 AC 85 ms
75,948 KB
testcase_11 AC 69 ms
71,440 KB
testcase_12 AC 69 ms
71,336 KB
testcase_13 AC 76 ms
76,276 KB
testcase_14 AC 99 ms
76,904 KB
testcase_15 AC 76 ms
76,072 KB
testcase_16 AC 73 ms
71,268 KB
testcase_17 AC 72 ms
71,300 KB
testcase_18 AC 71 ms
71,264 KB
testcase_19 AC 71 ms
71,084 KB
testcase_20 AC 72 ms
71,464 KB
testcase_21 AC 71 ms
71,100 KB
testcase_22 AC 70 ms
71,272 KB
testcase_23 AC 71 ms
71,080 KB
testcase_24 AC 70 ms
71,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
A = [input() for _ in range(H)]
#A = [input()[:-1] for _ in range(H)]
INF=10**10
dp = [[INF] * W for _ in range(H)]
dp[0][0] = 0

for h in range(H):
    for w in range(W):
        if h+1 < H:
            dp[h+1][w] = min(dp[h+1][w], dp[h][w] + (h+w+1 if A[h][w]=="k" else 1))
        if w+1 < W:
            dp[h][w+1] = min(dp[h][w+1], dp[h][w] + (h+w+1 if A[h][w]=="k" else 1))

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