結果

問題 No.1782 ManyCoins
ユーザー tktk_snsntktk_snsn
提出日時 2021-12-11 15:48:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 93,032 KB
最終ジャッジ日時 2023-09-27 03:34:54
合計ジャッジ時間 7,593 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
92,696 KB
testcase_01 AC 110 ms
92,528 KB
testcase_02 AC 107 ms
92,612 KB
testcase_03 AC 97 ms
92,592 KB
testcase_04 AC 97 ms
92,500 KB
testcase_05 WA -
testcase_06 AC 98 ms
92,592 KB
testcase_07 AC 97 ms
92,644 KB
testcase_08 AC 98 ms
92,756 KB
testcase_09 AC 105 ms
92,616 KB
testcase_10 AC 101 ms
92,600 KB
testcase_11 AC 102 ms
92,424 KB
testcase_12 AC 107 ms
92,592 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 101 ms
92,772 KB
testcase_48 AC 90 ms
92,484 KB
testcase_49 WA -
testcase_50 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""Lの上位20bit, 下位20bitで分けて半分全列挙"""
U = 1 << 20

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

dp = [0] * U
dp[0] = 1
for w in W:
    for i in range(w, U):
        dp[i] |= dp[i-w]

dp_sum = [0] * (U + 1)
for i in range(1, U+1):
    dp_sum[i] = dp_sum[i-1] + dp[i-1]

ans = 0
for i in range(U):
    if dp[i]:
        target = L - (i << 20)
        target = min(target, U)
        if target < 0:
            break
        ans += dp_sum[target]

print(ans)
0