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

有可能a>b;改过后可AC,不过算法是n^2的。。。。

Posted by blablabla at 2007-04-30 11:51:22 on Problem 2355
In Reply To:哪位大虾帮我看一下为什么WA? Posted by:tigerhy1 at 2005-04-25 13:45:44
> #include <stdio.h>
> 
> int l1,l2,l3,c1,c2,c3;
> int n;
> int a,b;
> int distance[20002];
> int cost[20002];
> int i,j,td;
> 
> main()
> {
>     //freopen("2355.in","r",stdin);
>     //freopen("2355.out","w",stdout);
>     scanf("%d%d%d%d%d%d",&l1,&l2,&l3,&c1,&c2,&c3);
>     scanf("%d",&n);
>     scanf("%d%d",&a,&b);
>     for (i=2; i<=n; i++) scanf("%d",&distance[i]);
>     distance[1]=0;
>     for (i=1; i<=n; i++) cost[i]=1500000000;
>     cost[a]=0;
>     for (i=a; i<=b; i++)
>     {
>         for (j=i+1; j<=b; j++)
>         {
>             td=distance[j]-distance[i];
>             if (td<=l3)
>             {
>                 if (td==0) cost[j]=cost[i];
>                 if (td>0 && td<=l1 && cost[i]+c1<cost[j]) cost[j]=cost[i]+c1;
>                 if (td>l1 && td<=l2 && cost[i]+c2<cost[j]) cost[j]=cost[i]+c2;
>                 if (td>l2 && cost[i]+c3<cost[j]) cost[j]=cost[i]+c3; 
>             }
>             else break;
>         }    
>     }
>     printf("%d\n",cost[b]);
> }

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