結果

問題 No.2095 High Rise
ユーザー mkawa2mkawa2
提出日時 2022-10-07 22:03:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 1,005 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 87,100 KB
最終ジャッジ日時 2023-09-03 12:33:55
合計ジャッジ時間 5,148 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,540 KB
testcase_01 AC 71 ms
71,616 KB
testcase_02 AC 72 ms
71,352 KB
testcase_03 AC 71 ms
71,240 KB
testcase_04 AC 72 ms
71,084 KB
testcase_05 AC 72 ms
71,232 KB
testcase_06 AC 72 ms
71,344 KB
testcase_07 AC 73 ms
71,520 KB
testcase_08 AC 72 ms
71,340 KB
testcase_09 AC 73 ms
71,236 KB
testcase_10 AC 72 ms
71,432 KB
testcase_11 AC 73 ms
71,588 KB
testcase_12 AC 80 ms
76,708 KB
testcase_13 AC 80 ms
76,380 KB
testcase_14 AC 81 ms
76,720 KB
testcase_15 AC 81 ms
76,524 KB
testcase_16 AC 79 ms
76,688 KB
testcase_17 AC 101 ms
77,888 KB
testcase_18 AC 99 ms
77,880 KB
testcase_19 AC 86 ms
76,584 KB
testcase_20 AC 100 ms
77,308 KB
testcase_21 AC 115 ms
79,440 KB
testcase_22 AC 207 ms
86,844 KB
testcase_23 AC 211 ms
86,704 KB
testcase_24 AC 204 ms
86,908 KB
testcase_25 AC 222 ms
87,100 KB
testcase_26 AC 208 ms
86,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

n, m = LI()
aa = LLI(n)

if n==1:
    print(0)
    exit()

dp = aa[0][:]
mn = 0
for i in range(1, n):
    ndp = [inf]*m
    nxt = inf
    for j in range(m):
        ndp[j] = min(dp[j], mn+aa[i-1][j])+aa[i][j]
        nxt = min(nxt, ndp[j])
    mn = nxt
    dp = ndp

print(min(dp))
0