結果

問題 No.771 しおり
ユーザー mkawa2mkawa2
提出日時 2020-09-25 17:15:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,254 ms / 2,000 ms
コード長 1,194 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 134,868 KB
最終ジャッジ日時 2023-09-29 13:05:41
合計ジャッジ時間 20,073 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,223 ms
134,648 KB
testcase_01 AC 217 ms
84,288 KB
testcase_02 AC 98 ms
71,676 KB
testcase_03 AC 97 ms
71,684 KB
testcase_04 AC 100 ms
71,628 KB
testcase_05 AC 97 ms
71,592 KB
testcase_06 AC 99 ms
71,808 KB
testcase_07 AC 97 ms
71,664 KB
testcase_08 AC 126 ms
77,428 KB
testcase_09 AC 97 ms
71,640 KB
testcase_10 AC 96 ms
71,872 KB
testcase_11 AC 97 ms
71,768 KB
testcase_12 AC 97 ms
71,680 KB
testcase_13 AC 97 ms
71,652 KB
testcase_14 AC 125 ms
77,752 KB
testcase_15 AC 96 ms
71,884 KB
testcase_16 AC 105 ms
76,740 KB
testcase_17 AC 119 ms
77,340 KB
testcase_18 AC 97 ms
71,588 KB
testcase_19 AC 103 ms
76,760 KB
testcase_20 AC 101 ms
71,560 KB
testcase_21 AC 98 ms
71,624 KB
testcase_22 AC 104 ms
76,744 KB
testcase_23 AC 111 ms
77,544 KB
testcase_24 AC 119 ms
77,460 KB
testcase_25 AC 568 ms
105,560 KB
testcase_26 AC 136 ms
78,052 KB
testcase_27 AC 223 ms
84,320 KB
testcase_28 AC 407 ms
91,980 KB
testcase_29 AC 227 ms
84,468 KB
testcase_30 AC 1,250 ms
134,612 KB
testcase_31 AC 1,246 ms
134,728 KB
testcase_32 AC 143 ms
78,084 KB
testcase_33 AC 1,254 ms
134,736 KB
testcase_34 AC 1,254 ms
134,864 KB
testcase_35 AC 144 ms
78,228 KB
testcase_36 AC 126 ms
77,868 KB
testcase_37 AC 126 ms
78,064 KB
testcase_38 AC 141 ms
78,040 KB
testcase_39 AC 125 ms
77,812 KB
testcase_40 AC 562 ms
105,660 KB
testcase_41 AC 1,233 ms
134,668 KB
testcase_42 AC 1,209 ms
134,860 KB
testcase_43 AC 224 ms
84,304 KB
testcase_44 AC 1,204 ms
134,868 KB
testcase_45 AC 1,196 ms
134,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10**6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x)-1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

n=II()
inf=10**9
dp=[[inf]*n for _ in range(1<<n)]
ab=LLI(n)
for i in range(n):dp[1<<i][i]=0

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

for bit in range(1<<n):
    for i in range(n):
        if bit>>i&1==0:continue
        pre=dp[bit][i]
        if pre==inf:continue
        pa,pb=ab[i]
        for ni,(a,b) in enumerate(ab):
            if bit>>ni&1:continue
            nbit=bit|1<<ni
            chmin(nbit,ni,max(pre,pb-pa+a))

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