結果

問題 No.561 東京と京都
ユーザー URechaRechaURechaRecha
提出日時 2019-09-03 20:52:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 801 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 70,300 KB
最終ジャッジ日時 2024-06-06 21:02:32
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
16,128 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 31 ms
10,624 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 34 ms
10,880 KB
testcase_10 AC 50 ms
13,184 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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):
            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__":
    print(tokyo_and_kyoto())
0