#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); #define int ll int N,X; cin >> N >> X; vector A(N), B(N); int BASE = 100; rep(i,N) cin >> A[i], A[i] -= X, A[i] += BASE; rep(i,N) cin >> B[i]; int BSUM = accumulate(B.begin(), B.end(), 0); int MAX = 200 * 500; vector dp(MAX + 1, 1e9); dp[0] = 0; rep(i,N) { vector nt = dp; for(int s = 0; s <= MAX; s++) { if(s + A[i] <= MAX) nt[s + A[i]] = min(nt[s + A[i]], dp[s]); if(s + BASE <= MAX) nt[s + BASE] = min(nt[s + BASE], dp[s] + B[i]); } swap(nt, dp); } int ans = 1e9; for(int s = BASE * N; s <= MAX; s++) ans = min(ans, dp[s]); cout << (ans == ll(1e18) ? -1 : ans) << endl; }