結果

問題 No.134 走れ!サブロー君
ユーザー Nikkuniku029Nikkuniku029
提出日時 2021-08-28 17:17:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,487 ms / 5,000 ms
コード長 679 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,280 KB
最終ジャッジ日時 2024-05-01 16:01:32
合計ジャッジ時間 8,293 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 31 ms
10,624 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 64 ms
10,880 KB
testcase_04 AC 112 ms
11,136 KB
testcase_05 AC 227 ms
11,520 KB
testcase_06 AC 478 ms
12,160 KB
testcase_07 AC 1,117 ms
13,952 KB
testcase_08 AC 2,487 ms
17,280 KB
testcase_09 AC 2,475 ms
17,152 KB
testcase_10 AC 30 ms
10,624 KB
testcase_11 AC 30 ms
10,752 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 29 ms
10,752 KB
testcase_14 AC 29 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

nimotsu=[]
x,y=map(int,input().split())
n=int(input())
nimotsu.append((x,y,0))
for _ in range(n):
    nimotsu.append(tuple(map(float,input().split())))
n+=1
INF=10**18
dp=[[INF]*n for _ in range(1<<n)]
dp[0][0]=0

def t(weight):
    return (weight+100)/120

for s in range(1<<n):
    w=0
    # 今持っている荷物の重さ
    for j in range(n):
        if not (s>>j)&1:
            w+=nimotsu[j][2]
    for v in range(n):
        if (s>>v)&1:
            continue
        xv,yv,_ =nimotsu[v]
        for u in range(n):
            xu,yu,wu=nimotsu[u]
            dp[s|(1<<v)][v]=min(dp[s|(1<<v)][v],dp[s][u]+t(w)*(abs(xu-xv)+abs(yu-yv))+wu )

ans=dp[(1<<n)-1][0]
print(ans)
0