結果

問題 No.771 しおり
ユーザー mkawa2mkawa2
提出日時 2022-03-08 15:49:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 706 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 114,100 KB
最終ジャッジ日時 2023-09-30 22:00:26
合計ジャッジ時間 29,389 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,973 ms
113,792 KB
testcase_01 AC 277 ms
80,564 KB
testcase_02 AC 75 ms
71,064 KB
testcase_03 AC 73 ms
71,456 KB
testcase_04 AC 73 ms
71,504 KB
testcase_05 AC 74 ms
71,304 KB
testcase_06 AC 73 ms
71,292 KB
testcase_07 AC 74 ms
71,380 KB
testcase_08 AC 98 ms
76,312 KB
testcase_09 AC 73 ms
71,448 KB
testcase_10 AC 74 ms
71,208 KB
testcase_11 AC 74 ms
71,352 KB
testcase_12 AC 74 ms
71,344 KB
testcase_13 AC 76 ms
71,332 KB
testcase_14 AC 104 ms
76,964 KB
testcase_15 AC 73 ms
71,332 KB
testcase_16 AC 80 ms
75,756 KB
testcase_17 AC 93 ms
76,104 KB
testcase_18 AC 77 ms
71,532 KB
testcase_19 AC 81 ms
75,752 KB
testcase_20 AC 73 ms
71,416 KB
testcase_21 AC 74 ms
71,540 KB
testcase_22 AC 81 ms
75,784 KB
testcase_23 AC 91 ms
76,156 KB
testcase_24 AC 93 ms
76,396 KB
testcase_25 AC 992 ms
94,424 KB
testcase_26 AC 114 ms
77,348 KB
testcase_27 AC 282 ms
80,592 KB
testcase_28 AC 618 ms
84,988 KB
testcase_29 AC 281 ms
80,668 KB
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 141 ms
77,836 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 146 ms
77,628 KB
testcase_36 AC 109 ms
76,284 KB
testcase_37 AC 105 ms
76,276 KB
testcase_38 AC 142 ms
77,468 KB
testcase_39 AC 107 ms
77,096 KB
testcase_40 AC 949 ms
94,648 KB
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 285 ms
80,740 KB
testcase_44 TLE -
testcase_45 AC 1,982 ms
113,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
inf = (1 << 31)-1

def main():
    n = II()
    ab = LLI(n)

    dp = [[inf]*(1 << n) for _ in range(n)]
    for i in range(n): dp[i][1 << i] = 0

    def chmin(i, s, val):
        if val < dp[i][s]: dp[i][s] = val

    for s in range(1, 1 << n):
        for i, (ai, bi) in enumerate(ab):
            pre = dp[i][s]
            for j, (aj, bj) in enumerate(ab):
                if s >> j & 1: continue
                chmin(j, s | 1 << j, max(pre, bi+aj-ai))

    ans = min(dp[i][-1] for i in range(n))
    print(ans)

main()
0