結果

問題 No.1782 ManyCoins
ユーザー chineristACchineristAC
提出日時 2021-12-11 00:28:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 440 ms / 2,000 ms
コード長 1,607 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 86,508 KB
実行使用メモリ 90,460 KB
最終ジャッジ日時 2023-09-26 01:50:41
合計ジャッジ時間 11,207 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
74,712 KB
testcase_01 AC 117 ms
78,908 KB
testcase_02 AC 110 ms
74,532 KB
testcase_03 AC 110 ms
74,384 KB
testcase_04 AC 109 ms
74,732 KB
testcase_05 AC 108 ms
74,704 KB
testcase_06 AC 109 ms
74,416 KB
testcase_07 AC 109 ms
74,732 KB
testcase_08 AC 110 ms
74,516 KB
testcase_09 AC 112 ms
74,356 KB
testcase_10 AC 110 ms
74,620 KB
testcase_11 AC 110 ms
74,124 KB
testcase_12 AC 112 ms
74,696 KB
testcase_13 AC 149 ms
84,208 KB
testcase_14 AC 210 ms
83,340 KB
testcase_15 AC 235 ms
83,780 KB
testcase_16 AC 339 ms
88,156 KB
testcase_17 AC 360 ms
88,972 KB
testcase_18 AC 345 ms
89,588 KB
testcase_19 AC 114 ms
78,968 KB
testcase_20 AC 255 ms
85,224 KB
testcase_21 AC 196 ms
82,788 KB
testcase_22 AC 269 ms
85,308 KB
testcase_23 AC 440 ms
90,460 KB
testcase_24 AC 125 ms
86,312 KB
testcase_25 AC 165 ms
81,976 KB
testcase_26 AC 362 ms
89,268 KB
testcase_27 AC 166 ms
81,620 KB
testcase_28 AC 121 ms
86,564 KB
testcase_29 AC 167 ms
88,720 KB
testcase_30 AC 135 ms
87,036 KB
testcase_31 AC 224 ms
88,936 KB
testcase_32 AC 282 ms
89,240 KB
testcase_33 AC 432 ms
89,472 KB
testcase_34 AC 169 ms
88,912 KB
testcase_35 AC 168 ms
89,340 KB
testcase_36 AC 166 ms
82,668 KB
testcase_37 AC 149 ms
82,140 KB
testcase_38 AC 115 ms
78,872 KB
testcase_39 AC 117 ms
78,912 KB
testcase_40 AC 124 ms
80,516 KB
testcase_41 AC 130 ms
81,728 KB
testcase_42 AC 115 ms
79,520 KB
testcase_43 AC 120 ms
84,484 KB
testcase_44 AC 117 ms
79,164 KB
testcase_45 AC 125 ms
80,292 KB
testcase_46 AC 114 ms
79,024 KB
testcase_47 AC 114 ms
78,716 KB
testcase_48 AC 110 ms
74,288 KB
testcase_49 AC 109 ms
74,428 KB
testcase_50 AC 121 ms
86,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Dijkstra():
    class Edge():
        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost

    def __init__(self, V):
        self.G = [[] for i in range(V)]
        self._E = 0
        self._V = V

    @property
    def E(self):
        return self._E

    @property
    def V(self):
        return self._V

    def add_edge(self, _from, _to, _cost):
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        import heapq
        que = []
        d = [10**15] * self.V
        d[s] = 0
        heapq.heappush(que, (0, s))

        while len(que) != 0:
            cost, v = heapq.heappop(que)
            if d[v] < cost: continue

            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost
                    heapq.heappush(que, (d[e.to], e.to))
        return d

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,L = mi()
W = li()
m = min(W)


D = [L+1 for i in range(m)]
D[0] = 0
pq = [(0,0)]
while pq:
    d,v = heappop(pq)
    if D[v] < d:
        continue

    for w in W:
        if D[(v+w)%m] > D[v] + w:
            D[(v+w)%m] = D[v] + w
            heappush(pq,(D[v]+w,(v+w)%m))
res = 0
for r in range(m):
    if D[r] <= L:
        res += (L-D[r])//m + 1

print(res-1)
0