rt,不知道为啥挂了 30pts /ll /kk /kel
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAXN = 1e5 + 10;
/*
一眼贪心,鉴定为:纯纯的暴力。
*/
int n, m;
ll ans, x, y, a[MAXN], b[MAXN];
int main() {
// freopen("road.in", "r", stdin);
// freopen("road.out", "w", stdout);
scanf("%d%d", &n, &m);
for (int i = 2; i <= n; i++) scanf("%lld", &a[i]), a[i] += a[i - 1];
for (int i = 1; i <= n; i++) scanf("%lld", &b[i]); b[n] = 0;
for (int i = 2, k = 1; i <= n; i++) {
if (b[i] >= b[k]) continue; y = a[i] - a[k];
if (x < y) y -= x, ans += (ll)ceil((long double)y / m) * b[k], x = m - y % m;
else x -= y; k = i;
}
printf("%lld", ans);
}
/*
Register_int AK CSP
orz ZZP
orz MCW
orz CYZ
orz HHX
orz HYT
*/