結果

問題 No.971 いたずらっ子
ユーザー convexineqconvexineq
提出日時 2020-01-17 22:02:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 289 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 111,540 KB
最終ジャッジ日時 2024-04-25 02:01:18
合計ジャッジ時間 4,310 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 287 ms
111,288 KB
testcase_01 AC 289 ms
111,540 KB
testcase_02 AC 236 ms
103,248 KB
testcase_03 AC 241 ms
111,336 KB
testcase_04 AC 233 ms
109,204 KB
testcase_05 AC 241 ms
111,332 KB
testcase_06 AC 203 ms
102,816 KB
testcase_07 AC 58 ms
63,744 KB
testcase_08 AC 108 ms
84,224 KB
testcase_09 AC 105 ms
83,712 KB
testcase_10 AC 54 ms
63,360 KB
testcase_11 AC 43 ms
51,968 KB
testcase_12 AC 42 ms
51,584 KB
testcase_13 AC 50 ms
59,136 KB
testcase_14 AC 65 ms
65,920 KB
testcase_15 AC 49 ms
59,008 KB
testcase_16 AC 43 ms
52,352 KB
testcase_17 AC 43 ms
51,840 KB
testcase_18 AC 43 ms
51,584 KB
testcase_19 AC 42 ms
51,584 KB
testcase_20 AC 41 ms
52,096 KB
testcase_21 AC 42 ms
52,096 KB
testcase_22 AC 42 ms
51,712 KB
testcase_23 AC 42 ms
51,840 KB
testcase_24 AC 44 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#######################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,m,*d= [int(i) for i in read().split()]

#a,t,k = [int(i) for i in readline().split()]

h,w = [int(i) for i in readline().split()]
bbb = read().split()
b = [[i+j+1 if bij=="k" else 1 for j,bij in enumerate(bi)] for i,bi in enumerate(bbb)]
b[0][0] = 0
INF = 10**9

dp = [0]+[INF]*(w-1)
for bi in b:
    for j, bij in enumerate(bi):
        if j:
            dp[j] = min(dp[j],dp[j-1]) + bij
        else:
            dp[j] += bij
    

print(dp[-1])






0