小图灵65pt和洛谷35pt,分数差距有点大,大样例小样例都过了,为什么呢
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
#define F(x,y,z) for(int x=y;x<=z;x++)
#define D(x,y,z) for(int x=y;x>=z;x--)
int n, v[N], a[N], ans, d, minn = 0x3f3f3f3f, p, s[N], m[N], now;
int main() {
// freopen("road.in","r",stdin);
// freopen("road.out","w",stdout);
cin >> n >> d;
F(i, 1, n - 1) {
cin >> v[i];
}
F(i, 1, n) {
cin >> a[i];
if (a[i] < minn) {
minn = a[i];
p = i;
}
m[i] = p;
}
F(i, 1, n - 1) {
if (m[i] != i) {
v[m[i]] += v[i];
v[i] = 0;
}
}
F(i, 1, n - 1) {
if (now < 0) now = 0;
int cost = v[i] - now;
if (cost > 0) {
ans += (a[m[i]] * (cost / d + ((cost % d == 0) ? 0 : 1)));
now += (cost / d + ((cost % d == 0) ? 0 : 1)) * d;
}
now -= v[i];
// cout<<ans<<" "<<now<<endl;
}
cout << ans;
}