bitset对dp的优化,非常典型
#include <bits/stdc++.h> using namespace std; const int N = 1e4; bitset<N + N + 100> b; int main() { int a, c; while (~scanf("%d", &a)) { b.reset(); b[N] = 1; while (a--) { scanf("%d", &c); b |= (b << c) | (b >> c); } scanf("%d", &a); while (a--) { scanf("%d", &c); if (c > 10000) puts("NO"); else if (b[N + c]) puts("YES"); else puts("NO"); } } return 0; }