結果

問題 No.1701 half price
ユーザー 👑 H20H20
提出日時 2021-10-08 22:46:23
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 77,216 KB
最終ジャッジ日時 2023-09-30 11:53:40
合計ジャッジ時間 4,008 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,920 KB
testcase_01 AC 72 ms
71,248 KB
testcase_02 AC 109 ms
76,812 KB
testcase_03 AC 75 ms
71,124 KB
testcase_04 AC 111 ms
76,816 KB
testcase_05 AC 80 ms
76,420 KB
testcase_06 AC 332 ms
76,860 KB
testcase_07 AC 355 ms
76,764 KB
testcase_08 WA -
testcase_09 AC 74 ms
70,924 KB
testcase_10 AC 71 ms
71,124 KB
testcase_11 AC 72 ms
70,940 KB
testcase_12 AC 71 ms
71,176 KB
testcase_13 AC 70 ms
70,864 KB
testcase_14 AC 72 ms
71,076 KB
testcase_15 AC 70 ms
71,112 KB
testcase_16 AC 70 ms
71,048 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 71 ms
71,252 KB
testcase_21 AC 329 ms
77,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,W = map(int,input().split())
A = list(map(int, input().split())) 
ans = 0
for i in range(2 ** N):
    bag = []
    total = 0
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            bag.append(A[j])
            total += A[j]
    ok = total==W
    for j in range(2 ** len(bag)):
        temp = 0
        for k in range(len(bag)):
            if ((j >> k) & 1):
                temp+=bag[k]//2
        ok = ok or (total - temp == W)
    if ok:
        ans+=1
        print
print(ans)
0