結果

問題 No.561 東京と京都
コンテスト
ユーザー akitsugu777
提出日時 2019-07-19 14:50:02
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 391 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-08 00:38:02
合計ジャッジ時間 1,970 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n, d = map(int, input().split())

p = 't'
m = 0
T = 0
K = -d
for _ in range(n):
    t, k = map(int, input().split())
    T += t
    K += k
    if p == 't' and k - d > t:
        m += k - d
        p = 'k'
    elif p == 'k' and t - d > k:
        m += t - d
        p = 't'
    elif p == 't' and k - d <= t:
        m += t
    elif p == 'k' and t - d <= k:
        m += k

print(max(m, T, K))
0