結果

問題 No.771 しおり
ユーザー mkawa2mkawa2
提出日時 2022-03-08 14:04:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,756 ms / 2,000 ms
コード長 1,155 bytes
コンパイル時間 1,277 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 114,152 KB
最終ジャッジ日時 2023-09-30 19:56:27
合計ジャッジ時間 25,186 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,532 ms
113,864 KB
testcase_01 AC 245 ms
80,768 KB
testcase_02 AC 74 ms
71,236 KB
testcase_03 AC 74 ms
71,344 KB
testcase_04 AC 75 ms
71,040 KB
testcase_05 AC 75 ms
71,168 KB
testcase_06 AC 74 ms
71,168 KB
testcase_07 AC 72 ms
71,056 KB
testcase_08 AC 96 ms
76,600 KB
testcase_09 AC 74 ms
71,208 KB
testcase_10 AC 76 ms
71,272 KB
testcase_11 AC 75 ms
71,476 KB
testcase_12 AC 76 ms
71,496 KB
testcase_13 AC 75 ms
71,288 KB
testcase_14 AC 101 ms
76,552 KB
testcase_15 AC 74 ms
71,456 KB
testcase_16 AC 81 ms
76,160 KB
testcase_17 AC 97 ms
76,252 KB
testcase_18 AC 75 ms
71,492 KB
testcase_19 AC 81 ms
75,856 KB
testcase_20 AC 75 ms
71,428 KB
testcase_21 AC 76 ms
71,384 KB
testcase_22 AC 82 ms
76,036 KB
testcase_23 AC 91 ms
76,412 KB
testcase_24 AC 93 ms
76,396 KB
testcase_25 AC 823 ms
94,272 KB
testcase_26 AC 107 ms
76,348 KB
testcase_27 AC 245 ms
80,740 KB
testcase_28 AC 549 ms
85,244 KB
testcase_29 AC 250 ms
80,852 KB
testcase_30 AC 1,692 ms
114,152 KB
testcase_31 AC 1,756 ms
114,076 KB
testcase_32 AC 143 ms
77,812 KB
testcase_33 AC 1,713 ms
113,700 KB
testcase_34 AC 1,683 ms
113,816 KB
testcase_35 AC 139 ms
77,860 KB
testcase_36 AC 98 ms
76,368 KB
testcase_37 AC 102 ms
76,340 KB
testcase_38 AC 144 ms
77,624 KB
testcase_39 AC 101 ms
76,588 KB
testcase_40 AC 800 ms
94,508 KB
testcase_41 AC 1,694 ms
113,636 KB
testcase_42 AC 1,681 ms
113,636 KB
testcase_43 AC 252 ms
80,680 KB
testcase_44 AC 1,692 ms
113,876 KB
testcase_45 AC 1,523 ms
113,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
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)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

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)
0