标签:ffffff dfs ios end 关系 algo 最小 cin class
1 2 3 1 2 3 1 2 2 2
2
#include<iostream> #include<algorithm> #include<cmath> #define MAXN 10000 #define INF 0xFFFFFFFFFF long long L1,L2,L3,C1,C2,C3; long long cost(long long l1,long long l2) { if(abs(l1-l2)<=L1) return C1; else if(abs(l1-l2)<=L2) return C2; return C3; } long long min(long long a,long long b){ return a<b ? a : b ; } int main() { long long i,j,k,dp[MAXN]; long long start,end,N,L[MAXN]; while(cin>>L1>>L2>>L3>>C1>>C2>>C3) { cin>>start>>end; cin>>N; for(i=2;i<=N;i++) cin<<L[i]; L[1]=0; for(i=0;i<=MAXN;i++) dp[i]=INF; dp[start]=0; for(i=start;i<=end;i++) { for(j=i+1;j<=end&&(L[j]-L[i])<=L3;j++) dp[j]=min(dp[j],dp[i]+cost(L[i],L[j])); } cout<<dp[end]<<endl; } return 0; }
标签:ffffff dfs ios end 关系 algo 最小 cin class
原文地址:https://www.cnblogs.com/bernieloveslife/p/9736452.html