#include int ri() { int n; scanf("%d", &n); return n; } template using pqueue_inv = std::priority_queue, std::greater >; int main() { int n = ri(); assert(n >= 10); int additional = ri(); int a[n]; for (auto &i : a) i = ri(); int b[n]; for (auto &i : b) i = ri(); std::vector dist(n, 1000000000000000000); pqueue_inv > que; que.push({dist[0] = 0, 0}); while (que.size()) { auto i = que.top(); que.pop(); if (i.first != dist[i.second]) continue; int cur = i.second; if (cur != n - 1 && dist[cur + 1] > i.first + a[cur] + b[cur + 1]) que.push({ dist[cur + 1] = i.first + a[cur] + b[cur + 1], cur + 1}); if (cur < n - 2 && dist[cur + 2] > i.first + a[cur] + b[cur + 2] + additional) que.push({ dist[cur + 2] = i.first + a[cur] + b[cur + 2] + additional, cur + 2}); } printf("%" PRId64 "\n", *std::max_element(dist.begin(), dist.end())); return 0; }