結果

問題 No.561 東京と京都
ユーザー Ricky-yu
提出日時 2018-07-16 00:04:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 793 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-07 16:26:58
合計ジャッジ時間 1,857 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from __future__ import absolute_import
from __future__ import unicode_literals

D_C = input().split()
Tokyo = True
Total = 0
Tokyo_money = 0
Kyoto_money = 0-int(D_C[1])
for i in range(int(D_C[0])):
    money = input().split()
    Tokyo_money += int(money[0])
    Kyoto_money += int(money[1])
    if Tokyo:
       if int(money[0]) < int(money[1])-int(D_C[1]):
            Tokyo = False
            Total += int(money[1])-int(D_C[1])
       else:
           Total += int(money[0])
    else:
        if int(money[1]) < int(money[0])-int(D_C[1]):
            Tokyo = True
            Total += int(money[0])-int(D_C[1])
        else:
            Total += int(money[1])


    if Kyoto_money > Total:
        Total = Kyoto_money
    elif Tokyo_money > Total:
        Total = Tokyo_money

print(Total)
0