Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
百练过了,这里提交什么都是超时?#include<iostream> #include<vector> #include<list> #include<stack> #include<string.h> #include<math.h> #include<stdio.h> #include<sstream> #include<map> using namespace std; #define N 10005 #define Inf 99999999 #define inf -9999999 int dp[N]; int num[N] ={0}; int main(){ int l1,l2,l3,c1,c2,c3; cin>>l1>>l2>>l3>>c1>>c2>>c3; int n; cin>>n; int beg,end; cin>>beg>>end; if(beg>end){ int k =beg; beg =end; end =k; } for(int i=beg;i<=end;i++){ dp[i] =0x7fffffff; } num[1] = 0; for(int i=2;i<=n;i++){ cin>>num[i]; } dp[beg] = 0; for(int i=beg;i<end;i++){ for(int j=i+1;j<=end;j++){ int k =num[j]-num[i]; if(k<=l1&& dp[j] > dp[i] + c1){ dp[j] = min(dp[j],dp[i]+c1) ; } if(k<=l2&& dp[j] > dp[i] + c2){ dp[j] = min(dp[j],dp[i]+c2) ; } if(k<=l3&& dp[j] > dp[i] +c3){ dp[j] = min(dp[j],dp[i]+c3) ; } } } cout<<dp[end]<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator