Skip to content

Instantly share code, notes, and snippets.

@nafu
Created February 17, 2013 11:33
Show Gist options
  • Save nafu/4971089 to your computer and use it in GitHub Desktop.
Save nafu/4971089 to your computer and use it in GitHub Desktop.
#include <cstdio>
const int MAX_N = 50;
int main() {
int n, m, k[MAX_N];
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++) {
scanf("%d", &k[i]);
}
bool f = false;
for (int a = 0; a < n; a++) {
for (int b = 0; b < n; b++) {
for (int c = 0; c < n; c++) {
for (int d = 0; d < n; d++) {
if (k[a] + k[b] + k[c] + k[d] == m) {
f = true;
}
}
}
}
}
if (f) puts("Yes");
else puts("No");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment