結果

問題 No.134 走れ!サブロー君
ユーザー efunyoefunyo
提出日時 2020-03-27 22:26:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,556 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,040 KB
実行使用メモリ 13,148 KB
最終ジャッジ日時 2023-08-30 16:57:18
合計ジャッジ時間 9,094 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
13,148 KB
testcase_01 AC 23 ms
8,896 KB
testcase_02 AC 21 ms
8,760 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#https://yukicoder.me/problems/273

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    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(int, input().split())
    N = int(input())
    dest = [list(map(float, input().split())) for _ in range(N)] + [[sx, sy, 0]]
    #dp[s][itme]:sは既に届けた荷物, itemは最後に届けた荷物
    #         dp[s][item]はそこから最適に届けたときにかかる時間
    dp = [[inf]*(N) for _ in range(1<<N)]

    def dfs(s, item):
        if item==-1:
            cx, cy = sx, sy
        else:
            cx, cy = dest[item][0], dest[item][1]

        #残りの荷物
        W = 0
        for i in range(N):
            if s&(1<<i):
                continue
            W += dest[i][2]
        T = (W+100)/120

        if s == (1<<N)-1:
            return T*(abs(cx-sy)+abs(cy-sy))

        for i in range(N):
            if s&(1<<i):
                continue
            dp[s][item] = min(dp[s][item], dfs(s|(1<<i), i)+T*(abs(cx-dest[i][0])+abs(cy-dest[i][1])))
        return dp[s][item]

    dfs(0, -1)
    total_w = 0
    for x,y,w in dest:
        total_w += w
    print(min(dp[0])+total_w)

if __name__ == '__main__':
    main()
0