結果

問題 No.771 しおり
ユーザー sjikisjiki
提出日時 2021-09-26 23:42:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 134,104 KB
最終ジャッジ日時 2023-09-19 04:25:51
合計ジャッジ時間 17,771 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 75 ms
71,148 KB
testcase_03 WA -
testcase_04 AC 76 ms
71,524 KB
testcase_05 WA -
testcase_06 AC 76 ms
71,240 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 78 ms
71,560 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 76 ms
71,328 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1,003 ms
133,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inf=10**16
n = int(input())
xy = []


for _ in range(n):
    xi, yi = list(map(int, input().split()))

    xy.append([xi, yi])

def dist(i,j):
    a,b=xy[i]
    p,q=xy[j]
    return abs(b-a)+p


dp=[[-inf]*n for _ in range(1<<n)]
dp[0][0]=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):
        pre=dp[bit][i]
        if pre==-inf:continue
        for j in range(n):
            if bit>>j&1:continue
            chmin(bit|1<<j,j,dist(i,j))

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