結果
問題 | No.134 走れ!サブロー君 |
ユーザー | tktk_snsn |
提出日時 | 2020-12-21 18:25:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 277 ms / 5,000 ms |
コード長 | 797 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 81,600 KB |
実行使用メモリ | 80,304 KB |
最終ジャッジ日時 | 2023-10-21 11:46:37 |
合計ジャッジ時間 | 3,161 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge9 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,320 KB |
testcase_01 | AC | 48 ms
61,776 KB |
testcase_02 | AC | 39 ms
53,320 KB |
testcase_03 | AC | 104 ms
75,968 KB |
testcase_04 | AC | 107 ms
76,096 KB |
testcase_05 | AC | 151 ms
77,408 KB |
testcase_06 | AC | 157 ms
77,660 KB |
testcase_07 | AC | 166 ms
77,792 KB |
testcase_08 | AC | 263 ms
80,068 KB |
testcase_09 | AC | 277 ms
80,304 KB |
testcase_10 | AC | 39 ms
53,324 KB |
testcase_11 | AC | 39 ms
53,324 KB |
testcase_12 | AC | 39 ms
53,324 KB |
testcase_13 | AC | 38 ms
53,324 KB |
testcase_14 | AC | 38 ms
53,324 KB |
ソースコード
import sys input = sys.stdin.readline inf = 1e18 def velocity(w): return (w + 100.)/120. x0, y0 = map(int, input().split()) N = int(input()) M = N + 1 X = [0] * M; Y = [0] * M; W = [0] * M X[0] = x0 Y[0] = y0 for i in range(1, N + 1): x, y, w = input().split() X[i] = int(x) Y[i] = int(y) W[i] = float(w) dp = [[inf] * M for _ in range(1 << M)] dp[0][0] = 0 for bit in range(1 << M): weight = sum(W[i] for i in range(M) if ~(bit >> i) & 1) vel = velocity(weight) for s in range(M): for t in range(M): if ~(bit >> t) & 1: bit_next = bit | (1 << t) time = vel * (abs(X[s] - X[t]) + abs(Y[s] - Y[t])) + W[t] dp[bit_next][t] = min(dp[bit_next][t], dp[bit][s] + time) print(dp[(1 << M) - 1][0])