結果

問題 No.2095 High Rise
ユーザー 👑 tamatotamato
提出日時 2022-10-07 21:36:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 87,156 KB
最終ジャッジ日時 2023-09-03 00:44:05
合計ジャッジ時間 5,017 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,340 KB
testcase_01 AC 74 ms
71,324 KB
testcase_02 AC 72 ms
71,504 KB
testcase_03 AC 73 ms
71,356 KB
testcase_04 AC 73 ms
71,708 KB
testcase_05 AC 74 ms
71,332 KB
testcase_06 AC 73 ms
71,464 KB
testcase_07 AC 73 ms
71,536 KB
testcase_08 AC 72 ms
71,320 KB
testcase_09 AC 72 ms
71,440 KB
testcase_10 AC 73 ms
71,460 KB
testcase_11 AC 73 ms
71,544 KB
testcase_12 AC 84 ms
76,448 KB
testcase_13 AC 80 ms
76,192 KB
testcase_14 AC 80 ms
76,348 KB
testcase_15 AC 80 ms
76,220 KB
testcase_16 AC 79 ms
76,212 KB
testcase_17 AC 99 ms
77,876 KB
testcase_18 AC 94 ms
77,756 KB
testcase_19 AC 84 ms
76,544 KB
testcase_20 AC 98 ms
77,632 KB
testcase_21 AC 113 ms
78,680 KB
testcase_22 AC 211 ms
86,968 KB
testcase_23 AC 209 ms
86,960 KB
testcase_24 AC 211 ms
87,156 KB
testcase_25 AC 213 ms
86,880 KB
testcase_26 AC 217 ms
86,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
inf = 10 ** 17


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = []
    for _ in range(N):
        A.append(list(map(int, input().split())))
    
    if N == 1:
        print(0)
        exit()

    dp = A[0][:]
    mi = min(dp)
    for i in range(1, N):
        dp_new = [inf] * M
        for j in range(M):
            dp_new[j] = min(dp[j] + A[i][j], mi + A[i][j] + A[i-1][j])
        dp = dp_new
        mi = min(dp)
    print(mi)


if __name__ == '__main__':
    main()
0