結果
問題 |
No.971 いたずらっ子
|
ユーザー |
|
提出日時 | 2020-04-27 13:12:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 776 ms / 2,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 463 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 266,752 KB |
最終ジャッジ日時 | 2024-11-07 11:44:58 |
合計ジャッジ時間 | 8,327 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
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[-1][-1])