結果

問題 No.2064 Smallest Sequence on Grid
ユーザー DrDrpilotDrDrpilot
提出日時 2022-09-04 19:16:11
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 970 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 852,480 KB
最終ジャッジ日時 2024-04-29 19:13:29
合計ジャッジ時間 5,921 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
60,928 KB
testcase_01 AC 52 ms
60,800 KB
testcase_02 AC 50 ms
60,928 KB
testcase_03 AC 49 ms
60,800 KB
testcase_04 AC 50 ms
60,800 KB
testcase_05 AC 48 ms
60,544 KB
testcase_06 AC 49 ms
61,440 KB
testcase_07 AC 54 ms
60,800 KB
testcase_08 AC 54 ms
63,360 KB
testcase_09 AC 54 ms
63,232 KB
testcase_10 AC 59 ms
65,792 KB
testcase_11 AC 52 ms
65,280 KB
testcase_12 AC 55 ms
66,944 KB
testcase_13 AC 52 ms
66,176 KB
testcase_14 AC 52 ms
65,664 KB
testcase_15 AC 51 ms
65,408 KB
testcase_16 AC 52 ms
65,792 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 #

def I():return int(input())
def MAP():return map(int,input().split())
def MAPs():return map(str,input().split())
def LI(): return list(map(int,input().split()))
def TPL(): return tuple(map(int,input().split()))
def S():return input()
from collections import defaultdict,Counter,deque
from copy import deepcopy
from heapq import heapify,heappop,heappush
from bisect import bisect_left,bisect_right
from itertools import accumulate,product,permutations,combinations
from math import gcd,ceil,floor,sqrt
inf=10**18

h,w=MAP()
g=[S() for _ in range(h)]
dp=[['']*w for _ in range(h)]
dp[0][0]=g[0][0]
for i in range(h):
    for j in range(w):
        if i==j==0:
            continue
        if i==0:
            dp[i][j]=dp[i][j-1]+g[i][j]
        elif j==0:
            dp[i][j]=dp[i-1][j]+g[i][j]
        else:
            if dp[i-1][j]<dp[i][j-1]:
                dp[i][j]=dp[i-1][j]+g[i][j]
            else:
                dp[i][j]=dp[i][j-1]+g[i][j]
print(dp[-1][-1])
0