結果

問題 No.1701 half price
ユーザー titiatitia
提出日時 2021-10-08 22:17:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 275 ms / 3,000 ms
コード長 430 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 8,268 KB
最終ジャッジ日時 2023-09-30 10:39:45
合計ジャッジ時間 1,861 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,900 KB
testcase_01 AC 15 ms
7,804 KB
testcase_02 AC 42 ms
7,760 KB
testcase_03 AC 15 ms
7,796 KB
testcase_04 AC 58 ms
7,956 KB
testcase_05 AC 15 ms
7,784 KB
testcase_06 AC 144 ms
7,800 KB
testcase_07 AC 275 ms
7,796 KB
testcase_08 AC 15 ms
8,260 KB
testcase_09 AC 15 ms
7,760 KB
testcase_10 AC 15 ms
7,860 KB
testcase_11 AC 15 ms
7,856 KB
testcase_12 AC 15 ms
7,904 KB
testcase_13 AC 15 ms
7,748 KB
testcase_14 AC 15 ms
7,804 KB
testcase_15 AC 15 ms
7,824 KB
testcase_16 AC 16 ms
7,904 KB
testcase_17 AC 15 ms
8,108 KB
testcase_18 AC 15 ms
8,268 KB
testcase_19 AC 15 ms
8,184 KB
testcase_20 AC 15 ms
7,812 KB
testcase_21 AC 70 ms
7,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,W=map(int,input().split())
A=list(map(int,input().split()))
ANS=0

if W==0:
    X=0
    for a in A:
        if a==0:
            X+=1
    print(pow(2,X)-1)
    exit()


for j in range(1<<N):
    sc={0}

    for k in range(N):
        AD=[]
        if j & (1<<k)!=0:
            for x in sc:
                AD.append(x+A[k])
                AD.append(x+A[k]//2)
            sc=set(AD)

    if W in sc:
        ANS+=1

print(ANS)
0