結果

問題 No.1701 half price
ユーザー brthyyjpbrthyyjp
提出日時 2021-10-08 22:13:41
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 533 ms / 3,000 ms
コード長 486 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 86,740 KB
実行使用メモリ 77,376 KB
最終ジャッジ日時 2023-09-30 10:32:53
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,216 KB
testcase_01 AC 72 ms
76,588 KB
testcase_02 AC 117 ms
76,808 KB
testcase_03 AC 69 ms
76,604 KB
testcase_04 AC 104 ms
77,088 KB
testcase_05 AC 70 ms
76,432 KB
testcase_06 AC 526 ms
76,940 KB
testcase_07 AC 533 ms
77,136 KB
testcase_08 AC 65 ms
71,260 KB
testcase_09 AC 72 ms
76,360 KB
testcase_10 AC 70 ms
71,340 KB
testcase_11 AC 69 ms
76,240 KB
testcase_12 AC 68 ms
76,252 KB
testcase_13 AC 70 ms
76,188 KB
testcase_14 AC 70 ms
76,600 KB
testcase_15 AC 69 ms
76,364 KB
testcase_16 AC 66 ms
71,140 KB
testcase_17 AC 173 ms
77,376 KB
testcase_18 AC 73 ms
76,728 KB
testcase_19 AC 78 ms
76,652 KB
testcase_20 AC 66 ms
71,204 KB
testcase_21 AC 516 ms
77,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, w = map(int, input().split())
A =list(map(int, input().split()))
ans = 0
import itertools
used = set()
for p in itertools.product(range(3), repeat=n):
    s = 0
    t = 0
    for j in range(n):
        if p[j] == 0:
            continue
        elif p[j] == 1:
            s += A[j]
            t |= (1<<j)
        else:
            s += A[j]//2
            t |= (1<<j)
    if t == 0:
        continue
    if s == w and t not in used:
        ans += 1
        used.add(t)
print(ans)
0