#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("YES");}else{puts("NO");} #define MAX_N 200005 int main() { ll n, k; cin >> n >> k; ll a[n], b[n]; rep(i,n)cin >> a[i]; rep(i,n)cin >> b[i]; ll dp[n][2]; rep(i,n)rep(j,2)dp[i][j] = 0; rep(i,n){ if(i == 0){ dp[i][1] = a[i]; }else if(i == 1){ dp[i][0] = dp[i-1][1] + b[i]; dp[i][1] = dp[i][0] + a[i]; }else{ dp[i][0] = min(dp[i-1][1], dp[i-2][1]+k) + b[i]; dp[i][1] = dp[i][0] + a[i]; } } cout << dp[n-1][0] << endl; return 0; }