#include <iostream>
#include <stdio.h>
using namespace std;
#define MAX 2100000000000
long long int dist[10000];
long long int cost[10000];
int main()
{
long long int L1,L2,L3,C1,C2,C3;
while(scanf("%lld%lld%lld%lld%lld%lld",&L1,&L2,&L3,&C1,&C2,&C3)!=EOF)
<span style="white-space:pre"> </span>{
<span style="white-space:pre"> </span>long long int A = 0,B = 0;
long long int N = 0;
long long int i,j,t;
cin>>A>>B;
cin>>N;
for(t = 2; t <= N;t++)
cin>>dist[t];//输入到第二站,第三站... ...第N站的距离
dist[0] = dist[1] = 0;
if( A > B ){ //如果A>B,交换A,B
int temp = A;
A = B;
B = temp;
}
for(i = B;i >= A+1;i--)//计算出两两站之间的距离,dist[i]表示第i-1站到第i站的距离
{ //到第i站的花费初始化为MAX,无穷大
dist[i] = dist[i]-dist[i-1];
cost[i] = MAX;
}
cost[A] = 0;//A是起始站,在起始站花费为0
for(i = A+1;i <= B; i++)
{
long long int len = 0,tmp = 0;
for(j = i-1; j >= A;j--)
{
len += dist[j+1];//len为起始站到第i-1站的距离
if(len <= L1) //0<len<=L1,花费为C1;L1<len<=L2,花费为C2;L2<len<=L3,花费为C3
tmp = C1;
else if(len <= L2)
tmp = C2;
else if(len <=L3)
tmp = C3;
else
<span style="white-space:pre"> </span> break;//距离超过L3后,下车再买一张票
if(cost[i] > cost[j] + tmp)
cost[i] = cost[j] + tmp;
}
}
printf("%lld\n",cost[B]);
}
return 0;
}
九度OJ 1086 清华大学2011年机试 《最小花费》
最新推荐文章于 2021-03-03 22:35:02 发布