結果
問題 | No.561 東京と京都 |
ユーザー |
![]() |
提出日時 | 2019-09-03 21:04:26 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 739 bytes |
コンパイル時間 | 126 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 40,064 KB |
最終ジャッジ日時 | 2024-12-24 15:35:45 |
合計ジャッジ時間 | 31,486 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 TLE * 10 |
ソースコード
def tokyo_and_kyoto(inp=None): if inp == None: n,d= map(int,input().split()) inp_l = [] for _ in range(n): inp_l.append(input()) 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) 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]) else: 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())