結果

問題 No.1701 half price
ユーザー DrDrpilotDrDrpilot
提出日時 2022-01-20 19:04:53
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 555 ms / 3,000 ms
コード長 485 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 78,404 KB
最終ジャッジ日時 2023-08-15 18:19:18
合計ジャッジ時間 5,018 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,232 KB
testcase_01 AC 78 ms
76,072 KB
testcase_02 AC 139 ms
76,784 KB
testcase_03 AC 79 ms
75,780 KB
testcase_04 AC 134 ms
76,940 KB
testcase_05 AC 85 ms
76,460 KB
testcase_06 AC 539 ms
77,188 KB
testcase_07 AC 555 ms
77,268 KB
testcase_08 AC 71 ms
71,100 KB
testcase_09 AC 76 ms
75,864 KB
testcase_10 AC 71 ms
71,288 KB
testcase_11 AC 76 ms
75,720 KB
testcase_12 AC 76 ms
75,856 KB
testcase_13 AC 77 ms
75,808 KB
testcase_14 AC 77 ms
76,080 KB
testcase_15 AC 75 ms
75,720 KB
testcase_16 AC 70 ms
71,444 KB
testcase_17 AC 506 ms
78,404 KB
testcase_18 AC 88 ms
76,872 KB
testcase_19 AC 97 ms
77,280 KB
testcase_20 AC 70 ms
71,360 KB
testcase_21 AC 527 ms
76,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
n,w=map(int,input().split())
a=list(map(int,input().split()))
ans=set()
for bit in product(range(3),repeat=n):
    if sum(bit)==0:
        continue
    tmp=0
    for i in range(n):
        if bit[i]==1:
            tmp+=a[i]
        elif bit[i]==2:
            tmp+=a[i]//2
    if tmp==w:
        sel=[]
        for i in range(n):
            if bit[i]!=0:
                sel.append(i)
        sel=tuple(sel)
        ans.add(sel)
print(len(ans))
        
0