#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, F; std::cin >> N >> F; std::vector A(N), B(N), C(N); for (auto &a : A) { std::cin >> a; } for (auto &b : B) { std::cin >> b; } for (auto &c : C) { std::cin >> c; } std::vector dp[2]; int now = 0; dp[now].resize(N * F + 1, false); dp[1 - now].resize(N * F + 1, false); for (int i = 0; i < N; i++) { int nxt = 1 - now; for (int j = 0; j <= N * F; j++) { if (dp[now][j]) { dp[nxt][j] = true; if (j + A[i] <= N * F) { dp[nxt][j + A[i]] = true; } if (j + B[i] <= N * F) { dp[nxt][j + B[i]] = true; } if (j + C[i] <= N * F) { dp[nxt][j + C[i]] = true; } } } dp[nxt][A[i]] = true; dp[nxt][B[i]] = true; dp[nxt][C[i]] = true; now = nxt; int ans = 0; for (int j = 0; j <= N * F; j++) { ans += (dp[nxt][j]); } std::cout << ans << '\n'; } }