結果

問題 No.561 東京と京都
ユーザー URechaRechaURechaRecha
提出日時 2019-09-03 21:04:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 739 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2023-08-26 02:19:58
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,996 KB
testcase_01 AC 18 ms
7,868 KB
testcase_02 AC 18 ms
7,844 KB
testcase_03 AC 16 ms
7,812 KB
testcase_04 AC 16 ms
7,852 KB
testcase_05 AC 16 ms
7,804 KB
testcase_06 AC 17 ms
7,860 KB
testcase_07 AC 17 ms
7,896 KB
testcase_08 AC 17 ms
7,908 KB
testcase_09 AC 17 ms
8,264 KB
testcase_10 AC 27 ms
9,216 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):
            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())
0