結果

問題 No.771 しおり
ユーザー vwxyzvwxyz
提出日時 2022-04-30 07:12:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 978 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 86,728 KB
実行使用メモリ 135,448 KB
最終ジャッジ日時 2023-09-29 13:11:25
合計ジャッジ時間 17,413 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 804 ms
134,760 KB
testcase_01 AC 242 ms
85,548 KB
testcase_02 AC 69 ms
71,148 KB
testcase_03 AC 70 ms
71,316 KB
testcase_04 AC 73 ms
70,992 KB
testcase_05 AC 70 ms
71,420 KB
testcase_06 AC 73 ms
71,312 KB
testcase_07 AC 74 ms
71,372 KB
testcase_08 AC 109 ms
77,772 KB
testcase_09 AC 71 ms
71,244 KB
testcase_10 AC 69 ms
71,356 KB
testcase_11 AC 69 ms
71,376 KB
testcase_12 AC 70 ms
71,244 KB
testcase_13 AC 68 ms
71,296 KB
testcase_14 AC 124 ms
77,632 KB
testcase_15 AC 69 ms
71,324 KB
testcase_16 AC 71 ms
71,424 KB
testcase_17 AC 86 ms
76,632 KB
testcase_18 AC 69 ms
71,340 KB
testcase_19 AC 70 ms
71,368 KB
testcase_20 AC 68 ms
71,148 KB
testcase_21 AC 70 ms
71,160 KB
testcase_22 AC 69 ms
71,272 KB
testcase_23 AC 70 ms
71,356 KB
testcase_24 AC 84 ms
76,504 KB
testcase_25 AC 510 ms
105,940 KB
testcase_26 AC 146 ms
79,068 KB
testcase_27 AC 240 ms
85,280 KB
testcase_28 AC 355 ms
92,452 KB
testcase_29 AC 248 ms
85,568 KB
testcase_30 AC 924 ms
135,200 KB
testcase_31 AC 978 ms
135,176 KB
testcase_32 AC 153 ms
79,660 KB
testcase_33 AC 917 ms
135,008 KB
testcase_34 AC 940 ms
135,008 KB
testcase_35 AC 157 ms
80,112 KB
testcase_36 AC 133 ms
78,224 KB
testcase_37 AC 136 ms
78,416 KB
testcase_38 AC 154 ms
79,632 KB
testcase_39 AC 137 ms
78,604 KB
testcase_40 AC 459 ms
106,032 KB
testcase_41 AC 959 ms
135,180 KB
testcase_42 AC 859 ms
135,448 KB
testcase_43 AC 237 ms
85,300 KB
testcase_44 AC 871 ms
135,212 KB
testcase_45 AC 601 ms
134,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
A,B=[],[]
for _ in range(N):
    a,b=map(int,readline().split())
    b-=a
    A.append(a)
    B.append(b)
inf=1<<30
dp=[[inf]*N for bit in range(1<<N)]
for i in range(N):
    dp[1<<i][i]=0
for bit in range(1<<N):
    lst=[i for i in range(N) if bit&1<<i]
    l=len(lst)
    for j in range(l):
        for i in range(j):
            x,y=lst[i],lst[j]
            if bit&1<<x and bit&1<<y:
                dp[bit][x]=min(dp[bit][x],max(dp[bit^1<<x][y],B[y]+A[x]))
                dp[bit][y]=min(dp[bit][y],max(dp[bit^1<<y][x],B[x]+A[y]))
ans=min(dp[-1])
print(ans)
0