結果

問題 No.971 いたずらっ子
ユーザー ttrttr
提出日時 2020-01-29 20:48:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 109,824 KB
最終ジャッジ日時 2024-04-25 02:10:17
合計ジャッジ時間 3,805 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 224 ms
109,696 KB
testcase_01 AC 222 ms
109,568 KB
testcase_02 AC 179 ms
92,800 KB
testcase_03 AC 170 ms
109,824 KB
testcase_04 AC 166 ms
109,696 KB
testcase_05 AC 162 ms
109,568 KB
testcase_06 AC 136 ms
92,672 KB
testcase_07 AC 54 ms
62,976 KB
testcase_08 AC 89 ms
82,944 KB
testcase_09 AC 88 ms
83,968 KB
testcase_10 AC 46 ms
60,672 KB
testcase_11 AC 37 ms
51,840 KB
testcase_12 AC 36 ms
52,096 KB
testcase_13 AC 41 ms
59,136 KB
testcase_14 AC 69 ms
69,760 KB
testcase_15 AC 41 ms
58,496 KB
testcase_16 AC 40 ms
53,376 KB
testcase_17 AC 36 ms
52,224 KB
testcase_18 AC 37 ms
52,224 KB
testcase_19 AC 36 ms
52,096 KB
testcase_20 AC 42 ms
51,840 KB
testcase_21 AC 42 ms
52,096 KB
testcase_22 AC 43 ms
52,608 KB
testcase_23 AC 44 ms
52,224 KB
testcase_24 AC 42 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int, input().split())
L = [input() for _ in range(H)]

dist = [[10**13]*(W+1) for _ in range(H+1)]
dist[1][1] = 0
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue
        if L[i][j] == ".":
            dist[i+1][j+1] = min(dist[i][j+1], dist[i+1][j]) + 1
        else:
            dist[i+1][j+1] = min(dist[i][j+1], dist[i+1][j]) + (i+j+1)

print(dist[H][W])
0