結果

問題 No.2095 High Rise
ユーザー terasaterasa
提出日時 2022-10-07 23:15:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 107,116 KB
最終ジャッジ日時 2023-09-03 15:31:53
合計ジャッジ時間 6,407 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
72,552 KB
testcase_01 AC 97 ms
72,580 KB
testcase_02 AC 97 ms
72,380 KB
testcase_03 AC 97 ms
72,276 KB
testcase_04 AC 98 ms
72,516 KB
testcase_05 AC 97 ms
72,408 KB
testcase_06 AC 104 ms
72,324 KB
testcase_07 AC 96 ms
72,404 KB
testcase_08 AC 98 ms
72,128 KB
testcase_09 AC 96 ms
72,568 KB
testcase_10 AC 99 ms
72,412 KB
testcase_11 AC 99 ms
72,528 KB
testcase_12 AC 125 ms
77,788 KB
testcase_13 AC 111 ms
77,360 KB
testcase_14 AC 112 ms
77,576 KB
testcase_15 AC 107 ms
77,524 KB
testcase_16 AC 107 ms
77,640 KB
testcase_17 AC 129 ms
80,140 KB
testcase_18 AC 126 ms
80,276 KB
testcase_19 AC 109 ms
77,648 KB
testcase_20 AC 131 ms
79,736 KB
testcase_21 AC 153 ms
83,960 KB
testcase_22 AC 275 ms
106,992 KB
testcase_23 AC 264 ms
107,116 KB
testcase_24 AC 267 ms
106,888 KB
testcase_25 AC 267 ms
106,776 KB
testcase_26 AC 276 ms
106,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
# import pypyjit
import itertools
import heapq
import math
import bisect
from collections import deque, defaultdict
from functools import lru_cache, cmp_to_key


# for AtCoder Easy test
if __file__ == 'prog.py':
    pass
else:
    sys.setrecursionlimit(10 ** 6)
# pypyjit.set_param('max_unroll_recursion=-1')

input = sys.stdin.readline


def readints(): return map(int, input().split())
def readlist(): return list(readints())
def readstr(): return input()[:-1]


N, M = readints()
A = [readlist() for _ in range(N)]
if N == 1:
    print(0)
    exit()
INF = 1 << 60

dp = [[None for _ in range(M)] for _ in range(N)]
dp[0] = A[0]
for i in range(1, N):
    m = INF
    for j in range(M):
        dp[i][j] = dp[i - 1][j] + A[i][j]
        m = min(m, dp[i][j])
    for j in range(M):
        dp[i][j] = min(dp[i][j], m + A[i][j])
print(min(dp[N - 1]))
0