結果
| 問題 | No.134 走れ!サブロー君 | 
| コンテスト | |
| ユーザー |  mban | 
| 提出日時 | 2017-07-28 02:28:33 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 890 bytes | 
| コンパイル時間 | 367 ms | 
| コンパイル使用メモリ | 82,400 KB | 
| 実行使用メモリ | 95,876 KB | 
| 最終ジャッジ日時 | 2024-10-10 02:32:02 | 
| 合計ジャッジ時間 | 10,366 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 3 WA * 3 TLE * 1 -- * 8 | 
ソースコード
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)
            
            
            
        