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