class INPUT: def __init__(self): from sys import argv if argv[-1] in ["./Main.py","prog.py","Main.py"]:#Atcoder:./Main.py,Wandbox:prog.py,yukicoder:Main.py self.l=open(0).read().split()[::-1] else: self.l=open("_input.txt",mode="r").read().split()[::-1] self.length=len(self.l) return def stream(self,k=1,f=int,f2=False): assert(-1 return left all eclipse 等では_input.txtを使うこと。 listを変数で受け取るとき、必ずlistをTrueにすること。 """ from functools import lru_cache from collections import Counter from sys import setrecursionlimit setrecursionlimit(10000000) N,W=pin(2) A=pin(0) if W==0 and A==[0]*N: exit(print(pow(2,N)-1)) n=pow(2,N) b=[[Counter()for __ in [0]*n]for _ in [0]*N] cnt=[[Counter()for __ in [0]*n]for _ in [0]*N] f=[pow(2,i)for i in range(N)] @lru_cache(maxsize=10000000) def rec(m,w,d): if m==0: if w==0: #print(d) return set([d]) else: return set([0]) return rec(m-1,w-A[m-1],d+f[m-1])|rec(m-1,w-A[m-1]//2,d+f[m-1])|rec(m-1,w,d) ans=rec(N,W,0) #print(ans) print(len(ans)-1) # for i in cnt: # print(i)