結果

問題 No.134 走れ!サブロー君
ユーザー rlangevinrlangevin
提出日時 2023-11-06 12:36:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 212 ms / 5,000 ms
コード長 779 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 82,660 KB
最終ジャッジ日時 2023-11-06 12:37:02
合計ジャッジ時間 2,408 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,576 KB
testcase_01 AC 50 ms
64,372 KB
testcase_02 AC 36 ms
53,576 KB
testcase_03 AC 84 ms
76,020 KB
testcase_04 AC 93 ms
76,392 KB
testcase_05 AC 100 ms
76,724 KB
testcase_06 AC 117 ms
77,712 KB
testcase_07 AC 127 ms
79,156 KB
testcase_08 AC 205 ms
82,640 KB
testcase_09 AC 212 ms
82,660 KB
testcase_10 AC 38 ms
53,576 KB
testcase_11 AC 37 ms
53,576 KB
testcase_12 AC 37 ms
53,576 KB
testcase_13 AC 37 ms
53,576 KB
testcase_14 AC 37 ms
53,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x, y = map(int, input().split())
N = int(input())
X, Y = [x] * (N + 2), [y] * (N + 2)
W = [0] * (N + 2)
for i in range(N):
    X[i + 1], Y[i + 1], W[i + 1] = map(float, input().split())
sm = sum(W)

N2 = 1 << (N + 2)
inf = 1e18
dp = [[inf] * (N + 2) for i in range(N2)]
dp[1][0] = 0

def dist(i, j, t):
    return (abs(X[i] - X[j]) + abs(Y[i] - Y[j]))*t

for s in range(1, N2):
    now = 0
    for i in range(N + 2):
        if (s >> i) & 1:
            now += W[i]
    T = (sm - now + 100)/120

    for i in range(N + 2):
        if (s >> i) & 1 == 0:
            continue
        for j in range(N + 2):
            if (s >> j) & 1:
                continue
            ns = s | (1 << j)
            dp[ns][j] = min(dp[ns][j], dp[s][i] + dist(i, j, T) + W[j])

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