#include <bits/stdc++.h> using namespace std; struct uns_t {} uns; template <typename Element, typename Head, typename ...Args> auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template <typename Element, typename Head, typename ...Args> auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } int main() { constexpr int inf = INT_MAX / 4; int n, x; cin >> n >> x; auto a = vec<int>(uns, n); auto b = vec<int>(uns, n); for (auto &e : a) cin >> e; for (auto &e : b) cin >> e; for (auto &e : a) { e -= x; e *= -1; } sort(begin(a), end(a)); if (0 < a[0]) { cout << -1 << endl; return 0; } int all = accumulate(begin(a), end(a), 0); if (all <= 0) { cout << 0 << endl; return 0; } auto dp = vec<int>(inf, n + 1, all + 1); dp[0][0] = 0; for (int i = 1; i <= n; ++i) { for (int j = 0; j <= all; ++j) { if (a[i - 1] <= 0) { dp[i][j] = dp[i - 1][j]; } else { dp[i][j] = min(dp[i - 1][j], dp[i - 1][max(0, j - a[i - 1])] + b[i - 1]); } } } cout << dp[n][all] << endl; }