結果

問題 No.1701 half price
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-12 20:48:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 605 ms / 3,000 ms
コード長 546 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 77,204 KB
最終ジャッジ日時 2023-08-19 23:57:03
合計ジャッジ時間 4,726 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,404 KB
testcase_01 AC 71 ms
76,428 KB
testcase_02 AC 147 ms
77,096 KB
testcase_03 AC 69 ms
71,424 KB
testcase_04 AC 123 ms
77,204 KB
testcase_05 AC 76 ms
76,324 KB
testcase_06 AC 605 ms
77,064 KB
testcase_07 AC 602 ms
76,988 KB
testcase_08 AC 67 ms
71,400 KB
testcase_09 AC 76 ms
76,508 KB
testcase_10 AC 67 ms
71,500 KB
testcase_11 AC 66 ms
71,084 KB
testcase_12 AC 68 ms
71,160 KB
testcase_13 AC 70 ms
71,564 KB
testcase_14 AC 70 ms
71,216 KB
testcase_15 AC 72 ms
76,228 KB
testcase_16 AC 68 ms
71,420 KB
testcase_17 AC 78 ms
76,532 KB
testcase_18 AC 69 ms
71,368 KB
testcase_19 AC 74 ms
76,660 KB
testcase_20 AC 67 ms
71,236 KB
testcase_21 AC 602 ms
77,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
n,w=map(int,input().split())
a=list(map(int,input().split()))
ans=0

for i in product([0,1],repeat=n):
    t=i.count(1)
    if t == 0:
        continue
    for j in product([0,1],repeat=t):
        indj=0
        cntw=0
        for k in range(n):
            if i[k] == 1:
                if j[indj] == 1:
                    cntw += a[k]//2
                else:
                    cntw += a[k]
                indj+=1
        
        if cntw == w:
            ans+=1
            break
                
print(ans)
0