标签:acm
Description
Input
Output
Sample Input
1 2 3 2 3 1 0
Sample Output
17 41
#include <iostream> #include <cstring> using namespace std; int main() { int n,i,sum=0; int a[110]; while(cin >> n) { a[0]=0; sum=0; if(n==0) { break; } for(i=1;i<=n;i++) { cin >> a[i]; } for(i=1;i<=n;i++) { if(a[i]-a[i-1]>0) { sum+=(a[i]-a[i-1])*6; } else { sum+=-(a[i]-a[i-1])*4; } sum+=5; } cout << sum << endl; } return 0; }
标签:acm
原文地址:http://blog.csdn.net/zsc2014030403015/article/details/43484483