結果

問題 No.561 東京と京都
ユーザー URechaRecha
提出日時 2019-09-03 21:29:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 752 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 39,680 KB
最終ジャッジ日時 2024-12-24 17:37:59
合計ジャッジ時間 31,619 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

def tokyo_and_kyoto(inp=None):
    if inp == None:
        n,d= map(int,input().split())
    else:
        inp_l = inp.split("\n")
        n, d = map(int,inp_l.pop(0).split())
    heap = [[0,0]]
    for _ in range(n):
        l = len(heap)
        if inp == None:
            a,b =map(int,input().split())
        else:
            a, b = map(int, inp_l.pop(0).split())
        for _ in range(l):
            cur, money =heap.pop(0)
            if cur == 0:
                heap.append([0,money+a])
                heap.append([1,money+b-d])
            elif cur == 1:
                heap.append([0,money+a-d])
                heap.append([1,money+b])
    return max(heap,key= lambda x:x[1])[1]

if __name__ == "__main__":
    print(tokyo_and_kyoto())
0