t2 80分求调
#include<bits/stdc++.h>
using namespace std;
long long n,d,v[100005],a[100005];
long long ans=0,shengyu=0;
int main(){
cin>>n>>d;
if(n==1){
cout<<0;
return 0;
}
for(int i=1;i<n;i++){
cin>>v[i];
}
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<n;){
int j=i;
long long need=0;
while(a[j]>=a[i]&&j<=n){
need+=v[j];
j++;
}
if(need>shengyu){
if((need-shengyu)%d==0){
ans+=(need-shengyu)/d*a[i];
}
else{
ans+=((need-shengyu)/d+1)*a[i];
}
if((need-shengyu)%d!=0){
shengyu=((need-shengyu)/d+1)*d-(need-shengyu);
}
}
i=j;
}
cout<<ans;
return 0;
}
玄关