1031. Railway Tickets
2013-08-06 13:38
375 查看
The railway line “Yekaterinburg-Sverdlovsk” with several stations has been built. This railway line can be represented as a line segment, railway stations being points on it. The railway line starts at the station “Yekaterinburg” and finishes at the station “Sverdlovsk”, so stations are numbered starting from “Yekaterinburg” (it has number 1) and “Sverdlovsk” is the last station.
View Code
#include<iostream> #include<string> #include<cstring> #include<cstdio> #include<cmath> #define LL long long #define L long using namespace std; const long inf=1<<30; L L1,L2,L3,C1,C2,C3; L f[10010],i,j; L s,e,n; L dis[10010]; L judge(L d) { if(d<=L1&&d>0) return C1; if(d<=L2&&d>L1) return C2; if(d<=L3&&d>L2) return C3; } int main() { cin>>L1>>L2>>L3>>C1>>C2>>C3; cin>>n; cin>>s>>e; if(s>e) { L temp; temp=s; s=e; e=temp; } for(i=2;i<=n;i++) cin>>dis[i]; for(i=0;i<=n;i++) f[i]=inf; f[s]=0; for(i=s+1;i<=e;i++) { for(j=s;j<i;j++) if(dis[i]-dis[j]<=L3) { if(f[i]>f[j]+judge(dis[i]-dis[j])) f[i]=f[j]+judge(dis[i]-dis[j]); } } cout<<f[e]<<endl; return 0; }
View Code
相关文章推荐
- 【URAL1031】Railway tickets
- URAL 1031 Railway Tickets
- URAL 1031 Railway Tickets
- ural 1031 Railway Tickets
- URAL 1031. Railway Tickets(spfa)
- URAL1031——DP——Railway Tickets
- 递推DP URAL 1031 Railway Tickets
- poj 2355 Railway tickets 很纯的dp
- poj 1031 Fence 计算几何
- HDU 1031 Design T-Shirt
- bit 1031 Binary Tree Traversals
- [递归与分治算法][BOJ]1031-输油管道问题
- chapter 2:hdoj 1031(结构体的使用)
- COJ 1031木材加工(二分)
- EASY_ZJU_PAT ADVANCED LEVEL_1031 仔细分析,删繁就简
- PAT A 1031. Hello World for U (20)
- 题目1031:xxx定律
- NOJ 1031 建筑群最长坡值 (线性dp)
- bzoj1031 [JSOI2007]字符加密Cipher
- HDU 1114 || HOJ 1031 Piggy-Bank