来了。。。
就怪
往下看
哈哈
code:
#include<iostream>
#include<stdio.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
ll a[N], b[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll n, d, t, sum = 0, minn = 0x3f3f3f3f;
cin >> n >> d;
for (ll i = 1; i < n; i++)
cin >> a[i];
for (ll i = 1; i <= n; i++)
cin >> b[i];
for (ll i = 1; i < n; i++)
{
minn = min(minn, b[i]);
sum += (a[i] - t + d - 1) / d * minn;
t = (a[i] - t + d - 1) / d * d - a[i] + t;
}
cout << sum;
return 0;
}