結果

問題 No.2064 Smallest Sequence on Grid
ユーザー flygonflygon
提出日時 2022-09-18 22:40:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 362 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 39,232 KB
最終ジャッジ日時 2023-08-23 18:23:03
合計ジャッジ時間 6,548 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,680 KB
testcase_01 AC 15 ms
7,788 KB
testcase_02 AC 14 ms
7,808 KB
testcase_03 AC 14 ms
7,860 KB
testcase_04 AC 15 ms
7,832 KB
testcase_05 AC 15 ms
7,840 KB
testcase_06 AC 14 ms
7,752 KB
testcase_07 AC 14 ms
7,868 KB
testcase_08 AC 16 ms
7,916 KB
testcase_09 AC 15 ms
7,676 KB
testcase_10 AC 19 ms
7,760 KB
testcase_11 AC 19 ms
7,764 KB
testcase_12 AC 18 ms
7,752 KB
testcase_13 AC 20 ms
7,748 KB
testcase_14 AC 20 ms
7,684 KB
testcase_15 AC 19 ms
7,676 KB
testcase_16 AC 19 ms
7,796 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 = [""]*(w)
for i in range(h):
  new = [""]*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