序列型,水题
数据范围坑,需要开long long
题目里明确说两站之间只能用一张票,那与当前站距离大于L3的站直接break掉就好了
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define LL long long
using namespace std;
const LL MAXN = 200000 + 50;
LL L1,L2,L3,C1,C2,C3,n,A,B;
LL pos[MAXN],cnt,t[MAXN];
LL dp[MAXN];
LL get_cst(LL dis){
if(dis <= L1)return C1;
else if(dis <= L2)return C2;
else if(dis <= L3)return C3;
}
int main(){
scanf("%lld%lld%lld%lld%lld%lld",&L1,&L2,&L3,&C1,&C2,&C3);
scanf("%lld",&n);
scanf("%lld%lld",&A,&B);
for(LL i = 2;i <= n;i ++){
scanf("%lld",&pos[i]);
}
memset(dp,0x3f3f3f,sizeof(dp));
dp[A] = 0;
for(LL i = A;i <= B;i ++){
for(LL j = B - 1;j >= A;j --)
if(pos[i] - pos[j] <= L3)dp[i] = min(dp[i],dp[j] + get_cst(pos[i] - pos[j]));
else break;
}
printf("%lld",dp[B]);
return 0;
}