結果
問題 |
No.1782 ManyCoins
|
ユーザー |
![]() |
提出日時 | 2021-12-11 15:48:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 504 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 76,800 KB |
最終ジャッジ日時 | 2024-07-19 20:57:29 |
合計ジャッジ時間 | 5,843 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 37 |
ソースコード
"""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)