結果
| 問題 |
No.1701 half price
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-28 18:50:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 730 ms / 3,000 ms |
| コード長 | 739 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 82,444 KB |
| 実行使用メモリ | 76,416 KB |
| 最終ジャッジ日時 | 2024-09-30 14:49:28 |
| 合計ジャッジ時間 | 4,210 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
from itertools import product
def main():
N, W = map(int, input().split())
a = list(map(int, input().split()))
ctr = set()
for bit_3 in product(range(3), repeat=N):
if bit_3[0] == 0 and len(set(bit_3)) == 1:
continue
tmp_sum = 0
tmp_bit_n = 0
for idx, (bit, v) in enumerate(zip(bit_3, a)):
match bit:
case 0:
pass
case 1:
tmp_sum += v
tmp_bit_n += 2**idx
case 2:
tmp_sum += v // 2
tmp_bit_n += 2**idx
if tmp_sum == W:
ctr.add(tmp_bit_n)
print(len(ctr))
if __name__ == "__main__":
main()