n, k = read_line.split.map(&.to_i) a = read_line.split.map(&.to_i64) pre = a[0...(n // 2)] suf = a[(n // 2)..] sp = comb(pre) ss = comb(suf) sp.each do |s| if ss.includes?(k - s) puts "Yes" exit end end puts "No" def comb(a) set = Set(Int64).new dfs(a, 0, 0i64, set) return set end def dfs(a, i, sum, set) if i == a.size set << sum return end -1.upto(1) do |m| dfs(a, i + 1, sum + a[i] * m, set) end end