#include #include #include using namespace std; int main( void ) { int N, K; cin >> N >> K; vector sp( N ), fp( N ); for( int i = 0; i < N; i++ ) { cin >> fp[i]; } for( int i = 0; i < N; i++ ) { cin >> sp[i]; } int ans1 = 0, ans2 = 1; vector dp1( K + 1, 0 ); vector dp2( K + 1, 0 ); dp2[0] = 1; for( int i = 1; i <= K; i++ ) { for( int j = 0; j < N; j++ ) { if( i - fp[j] < 0 ) continue; if( dp1[i] < dp1[i - fp[j]] + sp[j] ) { dp1[i] = dp1[i - fp[j]] + sp[j]; dp2[i] = dp2[i - fp[j]]; } else if( dp1[i] == dp1[i - fp[j]] + sp[j] ) { dp2[i] += dp2[i - fp[j]]; } } if( ans1 < dp1[i] || ( ans1 == dp1[i] && ans2 < dp2[i].val() ) ) { ans1 = dp1[i]; ans2 = dp2[i].val(); } } cout << ans1 << endl << ans2 << endl; return 0; }