#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].second = 1; for (int i = 0; i < K; i++){ for (int j = 0; j < N; j++){ if (i + C[j] <= K){ int l = dp[i + C[j]].first, r = dp[i].first + D[j]; if (l < r){ dp[i + C[j]] = make_pair(r, dp[i].second); } else if (l == r){ dp[i + C[j]].second += dp[i].second; } } } } map m; int M = 0; for (int i = 0; i <= K; i++){ auto [k, v] = dp[i]; m[k] += v; M = max(M, k); } cout << M << '\n'; cout << m[M].val() << '\n'; }