Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

百练过了,这里提交什么都是超时?

Posted by csucyj at 2018-08-24 18:36:47 on Problem 2355
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator