結果

問題 No.134 走れ!サブロー君
ユーザー nebukuro09nebukuro09
提出日時 2016-10-06 14:55:12
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 709 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 16,096 KB
最終ジャッジ日時 2024-05-01 13:49:19
合計ジャッジ時間 1,205 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,816 KB
testcase_01 AC 9 ms
6,940 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 398 ms
16,096 KB
testcase_10 AC 9 ms
6,940 KB
testcase_11 AC 9 ms
6,940 KB
testcase_12 AC 9 ms
6,940 KB
testcase_13 AC 10 ms
6,940 KB
testcase_14 AC 9 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

sakaya = map(int, raw_input().split())
N = input()
points = [map(int, raw_input().split()) for _ in xrange(N)]
W = sum(p[2] for p in points)

def cost(p1, p2, weight):
    T = (weight+100.0)/120
    return abs(p1[0]-p2[0])*T + abs(p1[1]-p2[1])*T

mem = {}
def rec(p, b, w):
    if (p, b) in mem:
        return mem[(p, b)]
    w -= points[p][2]
    if b == ((1 << N) - 1):
        return cost(sakaya, points[p], w)+points[p][2]

    m = float('inf')
    for i in xrange(N):
        if (1 << i) & b:
            continue
        m = min(m, rec(i, (1<<i)+b, w)+cost(points[p], points[i], w)+points[p][2])
    mem[(p, b)] = m
    return m

print min(rec(x, 1<<x, W)+cost(sakaya, points[x], W) for x in xrange(N))
0