同样的代码小图灵 85pts,洛谷 5pts ?大概CCF数据下有多少分
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll in(){
ll x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-')f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
return x*f;
}
ll n,d,v[100005],a[100005],cnt,tmp=1,tot,ans;
int main(){
//freopen("road.in","r",stdin);
//freopen("road.out","w",stdout);
n=in(),d=in();
for (int i=1;i<n;i++)v[i]=in();
for (int i=1;i<=n;i++)a[i]=in();
for (int i=2;i<=n;i++){
tot+=v[i-1];
if (a[i]>a[tmp])continue;
if (tot<0){tmp=i;continue;}
int x;
if (tot%d==0)x=tot/d;
else x=tot/d+1;
ans+=x*a[tmp];
tot=tot-x*d;
tmp=i;
}
if (tmp!=n){
if (tot>0){
int x;
if (tot%a[tmp]==0)x=tot/a[tmp];
else x=tot/a[tmp]+1;
ans+=x*a[tmp];
}
}
printf ("%lld",ans);
return 0;
}