結果

問題 No.771 しおり
ユーザー roarisroaris
提出日時 2019-08-19 16:17:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,409 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 133,576 KB
最終ジャッジ日時 2023-09-29 12:59:24
合計ジャッジ時間 20,731 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,309 ms
133,472 KB
testcase_01 AC 211 ms
83,700 KB
testcase_02 AC 74 ms
71,304 KB
testcase_03 AC 72 ms
71,328 KB
testcase_04 AC 72 ms
71,408 KB
testcase_05 AC 73 ms
71,276 KB
testcase_06 AC 73 ms
71,160 KB
testcase_07 AC 75 ms
71,396 KB
testcase_08 AC 98 ms
76,648 KB
testcase_09 AC 72 ms
71,352 KB
testcase_10 AC 73 ms
71,424 KB
testcase_11 AC 74 ms
71,564 KB
testcase_12 AC 74 ms
71,236 KB
testcase_13 AC 75 ms
71,412 KB
testcase_14 AC 96 ms
76,728 KB
testcase_15 AC 72 ms
71,320 KB
testcase_16 AC 79 ms
76,264 KB
testcase_17 AC 96 ms
76,876 KB
testcase_18 AC 73 ms
71,292 KB
testcase_19 AC 79 ms
76,256 KB
testcase_20 AC 71 ms
71,316 KB
testcase_21 AC 73 ms
71,316 KB
testcase_22 AC 79 ms
76,120 KB
testcase_23 AC 84 ms
76,108 KB
testcase_24 AC 96 ms
76,844 KB
testcase_25 AC 760 ms
104,476 KB
testcase_26 AC 111 ms
78,148 KB
testcase_27 AC 225 ms
83,708 KB
testcase_28 AC 401 ms
90,580 KB
testcase_29 AC 236 ms
83,872 KB
testcase_30 AC 1,325 ms
133,464 KB
testcase_31 AC 1,371 ms
133,408 KB
testcase_32 AC 119 ms
79,032 KB
testcase_33 AC 1,331 ms
133,228 KB
testcase_34 AC 1,409 ms
133,328 KB
testcase_35 AC 119 ms
78,904 KB
testcase_36 AC 106 ms
77,956 KB
testcase_37 AC 105 ms
77,612 KB
testcase_38 AC 117 ms
78,916 KB
testcase_39 AC 111 ms
77,660 KB
testcase_40 AC 675 ms
105,040 KB
testcase_41 AC 1,394 ms
133,576 KB
testcase_42 AC 1,331 ms
133,472 KB
testcase_43 AC 214 ms
83,504 KB
testcase_44 AC 1,409 ms
133,560 KB
testcase_45 AC 1,284 ms
133,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A, B = [], []

for _ in range(N):
    Ai, Bi = map(int, input().split())
    A.append(Ai)
    B.append(Bi)

dp = [[10 ** 18 for _ in range(N)] for _ in range(1 << N)]

for v in range(N):
    dp[(1 << N) - 1][v] = 0
    
for S in range((1 << N) - 2, -1, -1):
    for u in range(N):
        if not S >> u & 1:
            for v in range(N):
                dp[S][v] = min(dp[S][v], max(dp[S | 1 << u][u], B[v] - A[v] + A[u]))

ans = 10 ** 18

for i in range(N):
    ans = min(ans, dp[1 << i][i])

print(ans)
0