結果

問題 No.134 走れ!サブロー君
ユーザー mbanmban
提出日時 2017-07-28 02:28:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 81,152 KB
最終ジャッジ日時 2024-04-18 09:14:54
合計ジャッジ時間 9,393 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
57,008 KB
testcase_01 AC 40 ms
56,252 KB
testcase_02 AC 37 ms
55,316 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import functools

line = input().split()
X0 = int(line[0])
Y0 = int(line[1])
N = int(input())
X = []
Y = []
W = []

for i in range(N):
    line = input().split()
    X.append(int(line[0]))
    Y.append(int(line[1]))
    W.append(float(line[2]))

sum = sum(W)
u = [False for i in range(N)]


def dist(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)


def time(dist, weight):
    return dist * (weight + 100) / 120


def func(pos, weight):
    if pos == -1:
        xx = X0
        yy = Y0
    else:
        xx = X[pos]
        yy = Y[pos]

    if weight == 0:
        return time(dist(X0, Y0, xx, yy), 0)

    result = 9999999
    for i in range(N):
        if u[i]:
            continue

        u[i] = True
        t = time(dist(xx, yy, X[i], Y[i]),weight) + func(i, weight - W[i])
        result = min(result, t)
        u[i] = False

    return result


print(func(-1, sum)+sum)
0