Wrong Answer.
代码如下:
#include<iostream> using namespace std; int main() { int n; while(cin>>n &&n) { int *a = new int[n]; int sumRun=0,sumStop=0,sumTotal=0; int i=0; a[0]=0; for (i=1;i<=n;i++) { cin>>a[i]; if (a[i]>a[i-1]) { sumRun = sumRun + ((a[i]-a[i-1])*6); } else if (a[i]<a[i-1]){ sumRun = sumRun + ((a[i-1]-a[i])*4); } else{ sumRun = sumRun + 0; } } sumStop = n*5; sumTotal = sumRun + sumStop; cout<<sumTotal<<endl; } return 0; }
时间: 2024-10-21 06:55:01