/* -*- coding: utf-8 -*- * * 3711.cc: No.3711 Udon, Tempura - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 100; const int MAX_M = 100; const int MAX_U = 100000; const int MAX_T = 1000; const int MAX_S = MAX_U + MAX_M * MAX_T; /* typedef */ using btst = bitset; /* global variables */ int us[MAX_N], ts[MAX_M]; /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", us + i); for (int i = 0; i < m; i++) scanf("%d", ts + i); btst dp; dp[0] = 1; for (int i = 0; i < m; i++) dp |= (dp << ts[i]); btst b; for (int i = 0; i < n; i++) b |= (dp << us[i]); printf("%d\n", (int)b.count()); return 0; }