#include #include using namespace std; using namespace atcoder; using ll=int; using ld=long double; ld pie=3.141592653589793; ll inf=1444999994; ll mod=1000000007; int main(){ ll n,x; cin >> n >> x; vectora(n),b(n); ll sum=0; for (ll i = 0; i < n; i++) { cin >> a[i]; sum+=a[i]; } for (ll i = 0; i < n; i++) { cin >> b[i]; } vector>dp(sum+1,vector(n,inf)); dp[sum][0]=0; dp[sum-a[0]][1]=b[0]; for (ll i = 1; i < n; i++) { for (ll j = i; j >=0; j--) { for (ll k = sum; k >=0; k--) { if (dp[k][j]==inf) { continue; } dp[k-a[i]][j+1]=min(dp[k-a[i]][j+1],dp[k][j]+b[i]); } } } ll ans=inf; for (ll i = 0; i <= sum; i++) { for (ll j = 0; j < n; j++) { if ((n-j)*x<=i) { ans=min(ans,dp[i][j]); } } } if (ans==inf) { cout << -1 << endl; return 0; }else{ cout << ans << endl; } }