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 |
哪位大虾帮我看一下为什么WA?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator