結果

問題 No.561 東京と京都
ユーザー akitsugu777akitsugu777
提出日時 2019-07-19 14:50:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 391 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 10,680 KB
実行使用メモリ 7,928 KB
最終ジャッジ日時 2023-08-26 21:16:55
合計ジャッジ時間 1,301 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,724 KB
testcase_01 AC 16 ms
7,928 KB
testcase_02 AC 16 ms
7,756 KB
testcase_03 AC 15 ms
7,744 KB
testcase_04 AC 15 ms
7,732 KB
testcase_05 AC 15 ms
7,916 KB
testcase_06 AC 15 ms
7,680 KB
testcase_07 AC 15 ms
7,788 KB
testcase_08 AC 14 ms
7,920 KB
testcase_09 WA -
testcase_10 AC 15 ms
7,800 KB
testcase_11 WA -
testcase_12 AC 15 ms
7,912 KB
testcase_13 AC 15 ms
7,772 KB
testcase_14 AC 15 ms
7,772 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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