代码如下
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 1e5 + 5;
int n, d;
int dis[M], dis0[M];
int price[M], nxt[M];
int ans;
signed main(void) {
scanf("%lld %lld", &n, &d);
for (int i = 1; i < n; ++i)
scanf("%lld", &dis0[i]);
for (int i = 2; i <= n; ++i)
dis[i] = dis0[i - 1] + dis[i - 1];
for (int i = 1; i <= n; ++i)
scanf("%lld", &price[i]);
int lastPrice = price[1];
int lastI = 1;
for (int i = 2; i < n; ++i)
if (price[i] < lastPrice) {
nxt[lastI] = i;
lastI = i;
lastPrice = price[i];
}
nxt[lastI] = n;
int dist, mov;
for (int i = 1; i < n; i = nxt[i]) {
dist = dis[nxt[i]] - dis[i];
ans += (dist - mov + d - 1) / d * price[i];
mov += (dist - mov + d - 1) / d * d - dist;
}
printf("%lld", ans);
return 0;
}
本来0pts也正常
离奇之处在于,我下载了的一个测试点的数据
in:
4 6279
90560 55497 63624
171 103 126 112
out:
4522
然而,诸位可以一试,代码能给出正确答案
评测得分0pts?!!
求dalao指导