結果

問題 No.561 東京と京都
ユーザー brthyyjpbrthyyjp
提出日時 2021-01-15 11:47:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 71,576 KB
最終ジャッジ日時 2023-08-16 19:38:03
合計ジャッジ時間 2,809 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,232 KB
testcase_01 AC 61 ms
71,232 KB
testcase_02 AC 62 ms
71,576 KB
testcase_03 AC 62 ms
71,392 KB
testcase_04 AC 64 ms
71,464 KB
testcase_05 AC 62 ms
71,328 KB
testcase_06 AC 61 ms
71,412 KB
testcase_07 AC 61 ms
71,520 KB
testcase_08 AC 62 ms
71,080 KB
testcase_09 AC 62 ms
71,376 KB
testcase_10 AC 61 ms
71,392 KB
testcase_11 AC 61 ms
71,460 KB
testcase_12 AC 62 ms
71,104 KB
testcase_13 AC 62 ms
71,340 KB
testcase_14 AC 62 ms
71,504 KB
testcase_15 AC 64 ms
71,396 KB
testcase_16 AC 64 ms
71,464 KB
testcase_17 AC 62 ms
71,080 KB
testcase_18 AC 63 ms
71,108 KB
testcase_19 AC 63 ms
71,232 KB
testcase_20 AC 63 ms
71,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d = map(int, input().split())
TK = []
for i in range(n):
    t, k = map(int, input().split())
    TK.append((t, k))

dp = [0, 0]
for i, (t, k) in enumerate(TK):
    nx = [0, 0]
    if i == 0:
        nx[0] = t
        nx[1] = k-d
    else:
        nx[0] = max(dp[0]+t, dp[1]+t-d)
        nx[1] = max(dp[0]+k-d, dp[1]+k)
    dp = nx
print(max(dp))
0