posts - 0,comments - 0,trackbacks - 0
动规水题,直接上代码。
#include<stdio.h>
long l1,l2,l3,c1,c2,c3,first,last,i,n,pay,j,temp;
long s[10001];
long f[10001];
long did(long a)
{
  
if (a<=l1)
    
return c1;
  
else if (a<=l2)
    
return c2;
  
else 
    
return c3;  
    
}
int main()
{
  scanf(
"%ld%ld%ld%ld%ld%ld",&l1,&l2,&l3,&c1,&c2,&c3);
  scanf(
"%ld",&n);
  scanf(
"%ld %ld",&first,&last);
  
if (first>last)
  {
    temp
=first;
    first
=last;
    last
=temp;
  }
  
for (i=1;i<=n-1;i++)
    scanf(
"%ld",&s[i+1]);
  
for (i=1;i<=n;i++)
    f[i]
=2100000000;
  f[first]
=0;
  
for (i=first+1;i<=last;i++)
    
for (j=i-1;j>=first;j--)
      
if (s[i]-s[j]>l3)
        
break;
      
else  
      {
        pay
=did(s[i]-s[j]);
        
if (f[i]>f[j]+pay)
          f[i]
=f[j]+pay;
      }
  printf(
"%ld",f[last]);
}
posted on 2011-07-05 23:09 梦转千寻 阅读(60) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理