結果

問題 No.1782 ManyCoins
ユーザー tamatotamato
提出日時 2021-12-12 19:03:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,329 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 87,768 KB
実行使用メモリ 115,008 KB
最終ジャッジ日時 2023-09-28 12:00:48
合計ジャッジ時間 18,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,888 KB
testcase_01 AC 111 ms
77,516 KB
testcase_02 AC 95 ms
71,980 KB
testcase_03 AC 96 ms
72,052 KB
testcase_04 AC 93 ms
71,944 KB
testcase_05 AC 96 ms
72,028 KB
testcase_06 AC 94 ms
71,616 KB
testcase_07 AC 95 ms
71,888 KB
testcase_08 AC 93 ms
72,016 KB
testcase_09 AC 97 ms
71,980 KB
testcase_10 AC 97 ms
71,804 KB
testcase_11 AC 96 ms
71,816 KB
testcase_12 AC 96 ms
72,004 KB
testcase_13 AC 230 ms
85,356 KB
testcase_14 AC 831 ms
114,492 KB
testcase_15 AC 410 ms
102,896 KB
testcase_16 AC 575 ms
109,276 KB
testcase_17 AC 830 ms
112,568 KB
testcase_18 AC 469 ms
110,564 KB
testcase_19 AC 108 ms
77,512 KB
testcase_20 AC 779 ms
107,972 KB
testcase_21 AC 936 ms
115,008 KB
testcase_22 AC 1,329 ms
111,556 KB
testcase_23 AC 1,142 ms
111,028 KB
testcase_24 AC 118 ms
85,008 KB
testcase_25 AC 772 ms
112,288 KB
testcase_26 AC 378 ms
99,524 KB
testcase_27 AC 1,283 ms
114,684 KB
testcase_28 AC 129 ms
84,812 KB
testcase_29 AC 180 ms
85,576 KB
testcase_30 AC 184 ms
93,780 KB
testcase_31 AC 227 ms
94,312 KB
testcase_32 AC 237 ms
94,248 KB
testcase_33 AC 238 ms
94,244 KB
testcase_34 AC 251 ms
93,784 KB
testcase_35 AC 276 ms
94,024 KB
testcase_36 AC 207 ms
86,284 KB
testcase_37 AC 153 ms
84,856 KB
testcase_38 AC 133 ms
85,524 KB
testcase_39 AC 117 ms
80,048 KB
testcase_40 AC 133 ms
85,612 KB
testcase_41 AC 142 ms
83,740 KB
testcase_42 AC 121 ms
84,992 KB
testcase_43 AC 128 ms
82,880 KB
testcase_44 AC 134 ms
85,564 KB
testcase_45 AC 134 ms
84,332 KB
testcase_46 AC 138 ms
79,180 KB
testcase_47 AC 143 ms
78,780 KB
testcase_48 AC 94 ms
71,740 KB
testcase_49 AC 94 ms
72,008 KB
testcase_50 AC 105 ms
85,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
inf = 10 ** 18


def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    N, L = map(int, input().split())
    W = list(map(int, input().split()))

    W.sort()
    w_max = W[-1]

    seen = [inf] * w_max
    que = deque([(0, 0)])
    seen[0] = 0
    while que:
        v, d = que.popleft()
        if d != seen[v]:
            continue
        for w in W[:-1]:
            u = v + w
            if u < w_max:
                if d < seen[u]:
                    seen[u] = d
                    que.appendleft((u, d))
            else:
                u -= w_max
                if d + 1 < seen[u]:
                    seen[u] = d + 1
                    que.append((u, d + 1))

    ans = 0
    for i in range(w_max):
        add = L // w_max
        if i:
            if L % w_max >= i:
                add += 1
        add -= seen[i]
        ans += max(0, add)
    print(ans)


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