結果

問題 No.561 東京と京都
ユーザー yassu0320yassu0320
提出日時 2021-07-07 08:12:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 7,996 KB
最終ジャッジ日時 2023-09-14 04:34:14
合計ジャッジ時間 1,558 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,900 KB
testcase_01 AC 19 ms
7,964 KB
testcase_02 AC 18 ms
7,960 KB
testcase_03 AC 16 ms
7,776 KB
testcase_04 AC 19 ms
7,888 KB
testcase_05 AC 17 ms
7,828 KB
testcase_06 AC 17 ms
7,996 KB
testcase_07 AC 18 ms
7,972 KB
testcase_08 AC 17 ms
7,772 KB
testcase_09 AC 17 ms
7,772 KB
testcase_10 AC 16 ms
7,900 KB
testcase_11 AC 17 ms
7,776 KB
testcase_12 AC 17 ms
7,852 KB
testcase_13 AC 17 ms
7,900 KB
testcase_14 AC 17 ms
7,956 KB
testcase_15 AC 16 ms
7,796 KB
testcase_16 AC 17 ms
7,960 KB
testcase_17 AC 17 ms
7,828 KB
testcase_18 AC 18 ms
7,912 KB
testcase_19 AC 18 ms
7,900 KB
testcase_20 AC 17 ms
7,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

INF: int = 2**62

def inputs(type_=int):
    ins = input().split(' ')
    ins = [x for x in ins if x != '']

    return list(map(type_, ins))

def main():
    ...
    n, d = inputs()
    n

    xs = [None] * n

    for i in range(n):
        xs[i] = inputs()
    xs = [[0, 0]] + xs
    n += 1

    dp = [[0, 0] for _ in range(n)]
    dp[0][0] = 0
    dp[0][1] = -INF
    for i in range(1, n):
        for s in range(2):
            dp[i][s] = max(dp[i-1][s] + xs[i][s], dp[i-1][1-s] + xs[i][s] - d)

    # from pprint import pprint
    # pprint(dp)
    print(max(dp[-1]))


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