結果

問題 No.2064 Smallest Sequence on Grid
ユーザー flygonflygon
提出日時 2022-09-18 22:44:29
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 360 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 308,992 KB
最終ジャッジ日時 2023-08-23 18:23:12
合計ジャッジ時間 8,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
75,748 KB
testcase_01 AC 69 ms
71,268 KB
testcase_02 AC 69 ms
71,588 KB
testcase_03 AC 71 ms
71,568 KB
testcase_04 AC 70 ms
71,196 KB
testcase_05 AC 70 ms
71,268 KB
testcase_06 AC 69 ms
71,364 KB
testcase_07 AC 69 ms
71,364 KB
testcase_08 AC 75 ms
76,076 KB
testcase_09 AC 74 ms
76,100 KB
testcase_10 AC 79 ms
75,980 KB
testcase_11 AC 79 ms
76,112 KB
testcase_12 AC 79 ms
76,100 KB
testcase_13 AC 78 ms
76,324 KB
testcase_14 AC 80 ms
76,120 KB
testcase_15 AC 79 ms
76,112 KB
testcase_16 AC 80 ms
76,360 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int,input().split())
s = [input() for i in range(h)]
dp = [0]*(w)
for i in range(h):
  new = [0]*w
  for j in range(w):
    if i == 0 and j == 0:
      new[j] = s[0][0]
    elif i == 0:
      new[j] = new[j-1] + s[i][j]
    elif j == 0:
      new[j] = dp[j] + s[i][j]
    else:
      new[j] = min(new[j-1], dp[j]) + s[i][j]
  dp = new
print(new[-1])
0