标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 13914 Accepted Submission(s): 5178
#include<stdio.h> #include<string.h> const int INF=0x3f3f3f; #define MIN(x,y)(x<y?x:y) double dp[110]; int s[110]; int L,N,C,T,VR,VT1,VT2; void DP(); void input(){ while(~scanf("%d",&L)){ scanf("%d%d%d",&N,&C,&T); scanf("%d%d%d",&VR,&VT1,&VT2); for(int i=1;i<=N;i++) scanf("%d",s+i); s[0]=0;s[N+1]=L; DP(); } } void DP(){ dp[0]=0; for(int i=0;i<=N+1;i++){ if(i)dp[i]=INF; for(int j=0;j<i;j++){ double time=0; if(s[i]-s[j]<=C) time=1.0*(s[i]-s[j])/VT1; else time=1.0*C/VT1+1.0*(s[i]-s[j]-C)/VT2; if(j>0)time+=T; dp[i]=MIN(dp[i],dp[j]+time); } } // printf("%.1lf %.1lf\n",dp[N+1],1.0*L/VR); if(dp[N+1]<1.0*L/VR)puts("What a pity rabbit!"); else puts("Good job,rabbit!"); } int main(){ input();//多写了个DP()wa了半天 return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4882118.html