n, k = read_line.split.map(&.to_i) a = read_line.split.map(&.to_i64) pre = a[0...(n // 2)] suf = a[(n // 2)..] po1, no1, mix1 = comb(pre) po2, no2, mix2 = comb(suf) if mix1.includes?(k) || mix2.includes?(k) puts "Yes" exit end po1.each do |s| if no2.includes?(k - s) || mix2.includes?(k - s) puts "Yes" exit end end no1.each do |s| if po2.includes?(k - s) || mix2.includes?(k - s) puts "Yes" exit end end mix1.each do |s| if po2.includes?(k - s) || no2.includes?(k - s) || mix2.includes?(k - s) puts "Yes" exit end end puts "No" def comb(a) po = Set(Int64).new no = Set(Int64).new mix = Set(Int64).new a.size.times do |i| dfs_po(a, i + 1, a[i], po, no, mix) dfs_no(a, i + 1, -a[i], po, no, mix) end return po, no, mix end def dfs_po(a, i, sum, set_po, set_no, set_mix) if i == a.size set_po << sum return end dfs_po(a, i + 1, sum, set_po, set_no, set_mix) dfs_po(a, i + 1, sum + a[i], set_po, set_no, set_mix) dfs_mix(a, i + 1, sum - a[i], set_po, set_no, set_mix) end def dfs_no(a, i, sum, set_po, set_no, set_mix) if i == a.size set_no << sum return end dfs_no(a, i + 1, sum, set_po, set_no, set_mix) dfs_mix(a, i + 1, sum + a[i], set_po, set_no, set_mix) dfs_no(a, i + 1, sum - a[i], set_po, set_no, set_mix) end def dfs_mix(a, i, sum, set_po, set_no, set_mix) if i == a.size set_mix << sum return end dfs_mix(a, i + 1, sum, set_po, set_no, set_mix) dfs_mix(a, i + 1, sum + a[i], set_po, set_no, set_mix) dfs_mix(a, i + 1, sum - a[i], set_po, set_no, set_mix) end