hdu1008(c++)
分清上升停留下降一步步来就是了
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int N,n,i,sumtime;
while (cin >> N&&N != 0)
{
sumtime = 0;
vector<int>v;
for (i = 0; i < N&&cin >> n; i++)
v.push_back(n);
sumtime = v[0] * 6;
for (i =1; i < N; i++)
{
if (v[i]>v[i - 1])
sumtime += 6 * (v[i] - v[i - 1]); //上升时间
else
sumtime += 4* (v[i - 1] - v[i]); //下降时间
}
sumtime += N * 5; //N次停留的时间
cout << sumtime << endl;
}
return 0;
}