#include #include #include #include using namespace std; int main(){ int n, x; cin >> n >> x; vector a(n), b(n); for(int i = 0; i < n; i++) cin >> a[i], a[i] -= x; for(int i = 0; i < n; i++) cin >> b[i]; if(*max_element(a.begin(),a.end()) < 0){ cout << -1 << endl; return 0; }else if(accumulate(a.begin(), a.end(), 0) >= 0){ cout << 0 << endl; return 0; } int k = -accumulate(a.begin(), a.end(), 0); vector dp(k+100, 1<<30); dp[0] = 0; for(int i = 0; i < n; i++){ if(a[i] >= 0) continue; for(int j = k+99; j >= -a[i]; j--){ dp[j] = min(dp[j], dp[j+a[i]]+b[i]); } } cout << *min_element(dp.begin()+k, dp.end()) << endl; return 0; }