#include #include using mint = atcoder::modint998244353; using namespace std; int main() { int N, K; cin >> N >> K; vector C(N), D(N); for (int i = 0; i < N; i++){ cin >> C[i]; } for (int i = 0; i < N; i++){ cin >> D[i]; } vector> dp(K + 1); dp[0][0] = 1; for (int i = 0; i < K; i++){ for (auto [k, v] : dp[i]){ for (int j = 0; j < N; j++){ if (i + C[j] <= K){ dp[i + C[j]][k + D[j]] += v; } } } } map m; int M = 0; for (int i = 0; i <= K; i++){ for (auto [k, v] : dp[i]){ m[k] += v; M = max(M, k); } } cout << M << ' ' << m[M].val() << '\n'; }