結果

問題 No.771 しおり
ユーザー wgrapewgrape
提出日時 2023-12-11 09:38:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,234 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 132,348 KB
最終ジャッジ日時 2023-12-11 09:39:14
合計ジャッジ時間 17,378 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,159 ms
132,348 KB
testcase_01 AC 154 ms
82,132 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 34 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 55 ms
66,388 KB
testcase_09 AC 35 ms
53,460 KB
testcase_10 AC 35 ms
53,460 KB
testcase_11 AC 35 ms
53,460 KB
testcase_12 AC 35 ms
53,460 KB
testcase_13 AC 35 ms
53,460 KB
testcase_14 AC 58 ms
68,464 KB
testcase_15 AC 36 ms
53,460 KB
testcase_16 AC 38 ms
59,448 KB
testcase_17 AC 58 ms
66,372 KB
testcase_18 AC 35 ms
53,460 KB
testcase_19 AC 39 ms
59,448 KB
testcase_20 AC 38 ms
53,460 KB
testcase_21 AC 36 ms
53,460 KB
testcase_22 AC 38 ms
59,448 KB
testcase_23 AC 45 ms
62,220 KB
testcase_24 AC 52 ms
66,372 KB
testcase_25 AC 526 ms
103,420 KB
testcase_26 AC 64 ms
68,608 KB
testcase_27 AC 157 ms
82,132 KB
testcase_28 AC 342 ms
89,340 KB
testcase_29 AC 167 ms
82,132 KB
testcase_30 AC 1,215 ms
132,348 KB
testcase_31 AC 1,234 ms
132,348 KB
testcase_32 AC 75 ms
72,704 KB
testcase_33 AC 1,232 ms
132,348 KB
testcase_34 AC 1,208 ms
132,348 KB
testcase_35 AC 82 ms
72,724 KB
testcase_36 AC 56 ms
68,608 KB
testcase_37 AC 58 ms
68,616 KB
testcase_38 AC 75 ms
72,724 KB
testcase_39 AC 58 ms
68,608 KB
testcase_40 AC 494 ms
103,420 KB
testcase_41 AC 1,212 ms
132,348 KB
testcase_42 AC 1,198 ms
132,348 KB
testcase_43 AC 156 ms
82,132 KB
testcase_44 AC 1,202 ms
132,348 KB
testcase_45 AC 1,122 ms
132,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

# dp[S][v] = 使用した本の集合S, 最後の本v, 最小値

INF = 1 << 60
dp = [[INF] * N for i in range(1 << N)]

for i in range(N):
    dp[1 << i][i] = 0
    
for status in range(1 << N):
    for from_v in range(N):
        if (status >> from_v) & 1 == 0:
            continue
        for to_v in range(N):
            if (status >> to_v) & 1:
                continue
            next_status = status | (1 << to_v)
            new_gap = (AB[from_v][1] - AB[from_v][0]) + AB[to_v][0]
            dp[next_status][to_v] = min(dp[next_status][to_v], max(dp[status][from_v], new_gap))

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