結果

問題 No.971 いたずらっ子
ユーザー hir355hir355
提出日時 2020-01-17 22:23:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 129,408 KB
最終ジャッジ日時 2024-04-25 02:02:15
合計ジャッジ時間 4,060 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 278 ms
124,160 KB
testcase_01 AC 272 ms
123,904 KB
testcase_02 AC 230 ms
107,520 KB
testcase_03 AC 222 ms
127,616 KB
testcase_04 AC 215 ms
129,408 KB
testcase_05 AC 238 ms
128,128 KB
testcase_06 AC 191 ms
109,952 KB
testcase_07 AC 57 ms
64,512 KB
testcase_08 AC 102 ms
82,944 KB
testcase_09 AC 96 ms
83,072 KB
testcase_10 AC 48 ms
61,440 KB
testcase_11 AC 37 ms
51,584 KB
testcase_12 AC 34 ms
51,968 KB
testcase_13 AC 41 ms
59,008 KB
testcase_14 AC 71 ms
71,424 KB
testcase_15 AC 44 ms
58,880 KB
testcase_16 AC 42 ms
53,376 KB
testcase_17 AC 40 ms
51,968 KB
testcase_18 AC 36 ms
51,968 KB
testcase_19 AC 34 ms
51,968 KB
testcase_20 AC 37 ms
52,096 KB
testcase_21 AC 38 ms
51,968 KB
testcase_22 AC 36 ms
52,224 KB
testcase_23 AC 36 ms
51,968 KB
testcase_24 AC 36 ms
51,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w=map(int,input().split())
s=[input()for _ in range(h)]
dp=[[float('inf')]*w for _ in range(h)]
dp[0][0]=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='k':
      cost=i+j+1
    else:
      cost=1
    if i>0:
      dp[i][j]=min(dp[i][j],dp[i-1][j]+cost)
    if j>0:
      dp[i][j]=min(dp[i][j],dp[i][j-1]+cost)
print(dp[h-1][w-1])
0