結果
| 問題 | 
                            No.971 いたずらっ子
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-04-27 13:12:09 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                OLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 702 bytes | 
| コンパイル時間 | 367 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 276,864 KB | 
| 最終ジャッジ日時 | 2024-11-21 13:26:54 | 
| 合計ジャッジ時間 | 11,400 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 4 | 
| other | WA * 15 OLE * 6 | 
ソースコード
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])