結果

問題 No.771 しおり
ユーザー maspymaspy
提出日時 2020-02-29 20:49:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 999 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 134,084 KB
最終ジャッジ日時 2023-09-29 13:02:50
合計ジャッジ時間 16,086 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 912 ms
133,784 KB
testcase_01 AC 181 ms
84,000 KB
testcase_02 AC 71 ms
71,356 KB
testcase_03 AC 73 ms
71,112 KB
testcase_04 AC 72 ms
71,420 KB
testcase_05 AC 73 ms
71,540 KB
testcase_06 AC 74 ms
71,120 KB
testcase_07 AC 74 ms
71,120 KB
testcase_08 AC 92 ms
76,688 KB
testcase_09 AC 75 ms
71,472 KB
testcase_10 AC 73 ms
71,564 KB
testcase_11 AC 73 ms
71,276 KB
testcase_12 AC 75 ms
71,580 KB
testcase_13 AC 74 ms
71,544 KB
testcase_14 AC 95 ms
76,820 KB
testcase_15 AC 74 ms
71,328 KB
testcase_16 AC 79 ms
76,152 KB
testcase_17 AC 87 ms
76,612 KB
testcase_18 AC 73 ms
71,268 KB
testcase_19 AC 76 ms
76,224 KB
testcase_20 AC 72 ms
71,536 KB
testcase_21 AC 75 ms
71,288 KB
testcase_22 AC 77 ms
75,960 KB
testcase_23 AC 80 ms
76,200 KB
testcase_24 AC 89 ms
76,732 KB
testcase_25 AC 494 ms
105,224 KB
testcase_26 AC 101 ms
76,932 KB
testcase_27 AC 182 ms
84,092 KB
testcase_28 AC 347 ms
90,960 KB
testcase_29 AC 182 ms
83,920 KB
testcase_30 AC 952 ms
134,080 KB
testcase_31 AC 999 ms
134,080 KB
testcase_32 AC 122 ms
78,744 KB
testcase_33 AC 989 ms
134,012 KB
testcase_34 AC 932 ms
133,872 KB
testcase_35 AC 123 ms
78,652 KB
testcase_36 AC 98 ms
77,040 KB
testcase_37 AC 100 ms
76,916 KB
testcase_38 AC 121 ms
78,728 KB
testcase_39 AC 99 ms
77,036 KB
testcase_40 AC 475 ms
105,220 KB
testcase_41 AC 962 ms
133,896 KB
testcase_42 AC 941 ms
134,084 KB
testcase_43 AC 191 ms
84,340 KB
testcase_44 AC 969 ms
134,008 KB
testcase_45 AC 976 ms
133,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
N = int(readline())
m = map(int, read().split())
AB = list(zip(m, m))

# %%
A, B = zip(*AB)

# # %%
INF = 10 ** 18
dp = [[INF] * N for _ in range(1 << N)]
for n in range(N):
    dp[1 << n][n] = 0

for subset in range(1 << N):
    for newbook in range(N):
        if subset & (1 << newbook):
            continue
        newset = subset | (1 << newbook)
        for lastbook in range(N):
            x = max(dp[subset][lastbook], B[lastbook] - A[lastbook] + A[newbook])
            if dp[newset][newbook] > x:
                dp[newset][newbook] = x

# %%
print(min(dp[-1]))
0