轩辕

运筹帷幄世界在我手中!

导航

杭电 acm 1008

#include<iostream>
using naemspace std;
int main()
{
int n,i,j,sum=0,str[100]={0};
cin>>n;
while(n!=0)
{
 for(i=1;i<=n;i++)
  cin>>str[i];
 sum+=n*5;
 for(i=0;i<n;i++)
  if(str[i+1]>str[i])
   sum+=(str[i+1]-str[i])*6;
  else
   sum+=(str[i]-str[i+1])*4;
  cout<<sum<<endl;
  sum=0;
  cin>>n;
}
return 0;
}

posted on 2011-08-18 16:26  峻华  阅读(128)  评论(0)    收藏  举报