結果
| 問題 |
No.134 走れ!サブロー君
|
| コンテスト | |
| ユーザー |
efunyo
|
| 提出日時 | 2020-03-27 23:04:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,799 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 82,776 KB |
| 実行使用メモリ | 80,964 KB |
| 最終ジャッジ日時 | 2025-01-02 09:45:36 |
| 合計ジャッジ時間 | 2,314 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 10 |
ソースコード
#https://yukicoder.me/problems/273
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate
#from itertools import product
from bisect import bisect_left,bisect_right
import heapq
from math import floor, ceil
#from operator import itemgetter
inf = 10**17
#mod = 10**9 + 7
sx,sy = map(float, input().split())
N = int(input())
dest = []
#荷物の総重
tw = 0
for _ in range(N):
x,y,w = map(float, input().split())
tw += w
dest.append([x+y, w])
#dp[s][itme]:sは既に届けた荷物, itemは最後に届けた荷物
# dp[s][item]はそこから最適に届けたときにかかる時間
dp = [[inf]*(N) for _ in range(1<<N)]
for i in range(N):
dp[0][i] = 0
res = []
for s in range(1<<N):
#残りの荷物
W = 0
for i in range(N):
if s&(1<<i):
continue
W += dest[i][1]
T = (W+100)/120
if s==(1<<N)-1:
for i in range(N):
res.append(dp[s][i]+T*abs(dest[i][0]-(sx+sy)))
elif s==0:
for i in range(N):
ns = s|(1<<i)
for j in range(N):
dp[ns][i] = min(dp[ns][i], dp[s][j]+T*(abs((sx+sy)-dest[i][0])))
else:
for i in range(N):
if s&(1<<i):
continue
ns = s|(1<<i)
for j in range(N):
dp[ns][i] = min(dp[ns][i], dp[s][j]+T*(abs(dest[j][0]-dest[i][0])))
print(min(res)+tw)
if __name__ == '__main__':
main()
efunyo