/* -*- coding: utf-8 -*- * * 1538.cc: No.1538 引きこもりさんは引き算が得意。 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 20; const int MAX_H = MAX_N / 2; const int MAX_M = 59049; // = 3^10 /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N]; ll ass[MAX_M]; /* subroutines */ inline int exp3(int n) { int e = 1; while (n--) e *= 3; return e; } inline ll t2sum(int t, int l, int r) { ll sum = 0; for (int i = l; i < r; i++, t /= 3) { int d = t % 3; if (d == 1) sum += as[i]; else if (d == 2) sum -= as[i]; } return sum; } bool afind(int m, ll a) { int l = lower_bound(ass, ass + m, a) - ass; return (l < m && ass[l] == a); } /* main */ int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", as + i); int a = (n + 1) / 2, b = n - a; int am = exp3(a), bm = exp3(b); for (int ts = 0; ts < am; ts++) ass[ts] = t2sum(ts, 0, a); sort(ass, ass + am); int m = unique(ass, ass + am) - ass; //for (int i = 0; i < m; i++) printf("%lld ", ass[i]); putchar('\n'); for (int ts = 0; ts < bm; ts++) { ll sum = t2sum(ts, a, n); //printf("%d -> %lld\n", ts, sum); if (afind(m, sum + k) || afind(m, sum - k)) { puts("Yes"); return 0; } } puts("No"); return 0; }