結果

問題 No.1701 half price
ユーザー chineristACchineristAC
提出日時 2021-10-08 21:57:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 3,000 ms
コード長 580 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 86,508 KB
実行使用メモリ 79,140 KB
最終ジャッジ日時 2023-09-30 10:01:29
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
74,104 KB
testcase_01 AC 122 ms
74,328 KB
testcase_02 AC 132 ms
78,892 KB
testcase_03 AC 122 ms
74,300 KB
testcase_04 AC 130 ms
79,016 KB
testcase_05 AC 125 ms
78,636 KB
testcase_06 AC 138 ms
79,140 KB
testcase_07 AC 137 ms
79,136 KB
testcase_08 AC 121 ms
74,076 KB
testcase_09 AC 121 ms
74,100 KB
testcase_10 AC 120 ms
74,520 KB
testcase_11 AC 122 ms
74,296 KB
testcase_12 AC 125 ms
74,116 KB
testcase_13 AC 131 ms
74,372 KB
testcase_14 AC 124 ms
74,464 KB
testcase_15 AC 125 ms
74,084 KB
testcase_16 AC 123 ms
74,332 KB
testcase_17 AC 132 ms
78,984 KB
testcase_18 AC 127 ms
78,596 KB
testcase_19 AC 127 ms
78,852 KB
testcase_20 AC 122 ms
74,100 KB
testcase_21 AC 135 ms
78,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random
from collections import deque
from heapq import heappush,heappop

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,W = mi()
A = li()

S = [0 for i in range(1<<N)]
for n in range(N):
    t = 2**n
    for i in range(t,2*t):
        S[i] = A[n] + S[i-t]

res = 0
for bit in range(1,1<<N):
    tmp = bit
    flag = False
    while tmp:
        k = S[tmp]//2 + S[bit-tmp]
        if k==W:
            flag = True
        tmp = (tmp-1)&bit
    if S[bit]==W:
        flag = True
    res += flag

print(res)
0