結果

問題 No.771 しおり
ユーザー brthyyjpbrthyyjp
提出日時 2021-10-15 00:46:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,165 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 134,108 KB
最終ジャッジ日時 2023-09-29 13:08:54
合計ジャッジ時間 17,722 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,165 ms
134,108 KB
testcase_01 AC 179 ms
84,056 KB
testcase_02 AC 71 ms
71,156 KB
testcase_03 AC 72 ms
71,404 KB
testcase_04 AC 74 ms
71,340 KB
testcase_05 AC 73 ms
71,400 KB
testcase_06 AC 72 ms
71,236 KB
testcase_07 AC 73 ms
71,340 KB
testcase_08 AC 93 ms
76,336 KB
testcase_09 AC 73 ms
71,208 KB
testcase_10 AC 74 ms
71,160 KB
testcase_11 AC 74 ms
71,276 KB
testcase_12 AC 76 ms
71,556 KB
testcase_13 AC 73 ms
71,600 KB
testcase_14 AC 98 ms
76,312 KB
testcase_15 AC 74 ms
71,424 KB
testcase_16 AC 78 ms
75,912 KB
testcase_17 AC 91 ms
76,588 KB
testcase_18 AC 74 ms
71,176 KB
testcase_19 AC 78 ms
75,784 KB
testcase_20 AC 73 ms
71,372 KB
testcase_21 AC 73 ms
71,668 KB
testcase_22 AC 78 ms
75,716 KB
testcase_23 AC 80 ms
75,788 KB
testcase_24 AC 90 ms
76,512 KB
testcase_25 AC 575 ms
105,340 KB
testcase_26 AC 107 ms
78,008 KB
testcase_27 AC 191 ms
83,840 KB
testcase_28 AC 354 ms
90,944 KB
testcase_29 AC 191 ms
84,220 KB
testcase_30 AC 1,106 ms
133,872 KB
testcase_31 AC 1,063 ms
134,104 KB
testcase_32 AC 131 ms
78,540 KB
testcase_33 AC 1,126 ms
133,712 KB
testcase_34 AC 1,005 ms
133,836 KB
testcase_35 AC 126 ms
78,608 KB
testcase_36 AC 104 ms
77,776 KB
testcase_37 AC 106 ms
77,720 KB
testcase_38 AC 128 ms
78,924 KB
testcase_39 AC 106 ms
77,908 KB
testcase_40 AC 538 ms
104,968 KB
testcase_41 AC 1,115 ms
133,988 KB
testcase_42 AC 1,039 ms
133,996 KB
testcase_43 AC 188 ms
84,220 KB
testcase_44 AC 1,056 ms
133,956 KB
testcase_45 AC 1,121 ms
133,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():

    n = int(input())
    A = []
    B = []
    for i in range(n):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    INF = 10**18
    dp = [[INF]*n for i in range(1<<n)]
    for i in range(n):
        dp[1<<i][i] = 0
    for s in range(1, 1<<n):
        for j in range(n):
            if (s>>j)&1:
                continue
            ns = s|(1<<j)
            res = INF
            for i in range(n):
                if not ((s>>i)&1):
                    continue
                res = min(res, max(dp[s][i], B[i]-A[i]+A[j]))
            dp[ns][j] = min(dp[ns][j], res)
    ans = min(dp[-1])
    print(ans)

if __name__ == '__main__':
    main()
0