結果

問題 No.1701 half price
ユーザー tobusakanatobusakana
提出日時 2022-12-03 13:45:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2024-04-18 22:46:42
合計ジャッジ時間 2,198 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,840 KB
testcase_01 AC 42 ms
52,224 KB
testcase_02 AC 55 ms
63,616 KB
testcase_03 AC 38 ms
52,096 KB
testcase_04 AC 52 ms
63,488 KB
testcase_05 AC 40 ms
52,224 KB
testcase_06 AC 61 ms
68,736 KB
testcase_07 AC 84 ms
76,288 KB
testcase_08 WA -
testcase_09 AC 38 ms
52,224 KB
testcase_10 AC 39 ms
51,968 KB
testcase_11 AC 38 ms
52,096 KB
testcase_12 AC 40 ms
52,224 KB
testcase_13 AC 38 ms
51,840 KB
testcase_14 AC 39 ms
51,968 KB
testcase_15 AC 43 ms
58,624 KB
testcase_16 AC 37 ms
51,968 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 40 ms
51,968 KB
testcase_21 AC 348 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,W = map(int,input().split())
A = list(map(lambda x:int(x) // 2,input().split()))

ans = 0
for status in range(1 << N):
    items = []
    for i in range(N):
        if (status >> i) & 1:
            items.append(A[i])
    rest = W - sum(items)
    if rest < 0:
        continue
    if rest == 0:
        ans += 1
        continue
    # itemsから幾つかを選んでrestに出来るか
    M = len(items)
    for bits in range(1 << M):
        val = 0
        for i in range(N):
            if (bits >> i) & 1:
                val += items[i]
                if val >= rest:
                    break
        if val == rest:
            ans += 1
            break
                
print(ans)
0