結果

問題 No.2064 Smallest Sequence on Grid
ユーザー ytftytft
提出日時 2022-09-03 19:30:10
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 470 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 851,712 KB
最終ジャッジ日時 2024-04-28 16:45:47
合計ジャッジ時間 5,478 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,840 KB
testcase_01 AC 42 ms
51,712 KB
testcase_02 AC 41 ms
52,096 KB
testcase_03 AC 42 ms
51,712 KB
testcase_04 AC 42 ms
51,584 KB
testcase_05 AC 42 ms
51,712 KB
testcase_06 AC 42 ms
52,224 KB
testcase_07 AC 42 ms
51,968 KB
testcase_08 AC 50 ms
59,520 KB
testcase_09 AC 48 ms
59,008 KB
testcase_10 AC 54 ms
61,824 KB
testcase_11 AC 54 ms
61,056 KB
testcase_12 AC 55 ms
60,672 KB
testcase_13 AC 57 ms
61,440 KB
testcase_14 AC 55 ms
62,336 KB
testcase_15 AC 54 ms
61,056 KB
testcase_16 AC 54 ms
61,696 KB
testcase_17 MLE -
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 #

import sys
input=lambda:sys.stdin.readline().rstrip()
def compare(a,b):
	return a if a<b else b
H,W=map(int,input().split())
S=[input() for i in range(H)]
dp=[['' for i in range(W)] for j in range(H)]
dp[H-1][W-1]=S[H-1][W-1]
for i in range(H-2,-1,-1):
	dp[i][W-1]=S[i][W-1]+dp[i+1][W-1]
for i in range(W-2,-1,-1):
	dp[H-1][i]=S[H-1][i]+dp[H-1][i+1]
for i in range(H-2,-1,-1):
	for j in range(W-2,-1,-1):
		dp[i][j]=S[i][j]+compare(dp[i+1][j],dp[i][j+1])
print(dp[0][0])
0