#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,X; cin >> N >> X; vector A(N), B(N); rep(i,N) cin >> A[i]; rep(i,N) cin >> B[i]; ll SUMB = accumulate(B.begin(), B.end(), 0LL); ll ans = 1e18; ll MAX_A = accumulate(A.begin(), A.end(), 0LL); vector> dp(MAX_A + 1, vector(N + 1, -1e18)); dp[0][0] = 0; rep(i,N) { vector> nt = dp; for(int s = 0; s <= MAX_A; s++) for(int k = 0; k <= N; k++) if(s + A[i] <= MAX_A && k + 1 <= N) nt[s + A[i]][k + 1] = max(nt[s + A[i]][k + 1], dp[s][k] + B[i]); swap(dp, nt); } for(int n = 1; n <= N; n++) { for(int s = n * X; s <= MAX_A; s++) { ans = min(ans, SUMB - dp[s][n]); } } cout << (ans == ll(1e18) ? -1 : ans) << endl; }