結果
問題 | No.561 東京と京都 |
ユーザー |
![]() |
提出日時 | 2019-09-03 20:46:09 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 754 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-12-24 15:08:19 |
合計ジャッジ時間 | 1,718 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 4 |
other | RE * 17 |
ソースコード
def tokyo_and_kyoto(inp): inp_l = inp.split("\n") n, d = map(int,inp_l.pop(0).split()) heap = [[[0],0]] for _ in range(n): l = len(heap) a, b = map(int, inp_l.pop(0).split()) for _ in range(l): path, money =heap.pop(0) if path[-1] == 0: heap.append([path+[0],money+a]) heap.append([path+[1],money+b-d]) else: heap.append([path+[0],money+a-d]) heap.append([path+[1],money+b]) heap.sort(key= lambda x:x[1],reverse=True) return heap[0][1] if __name__ == "__main__": a =" " inp = [] while " " in a: a = input() inp.append(a) inp = "\n".join(inp) print(tokyo_and_kyoto(inp))