#include "iostream" using namespace std; int main() { while(1) { int n; cin >> n; if (n == 0) break; int m1=0; int m2=0; int time=0; for(int i=0;i<n;i++) { cin >> m2; if(m2 > m1) time = time + (m2-m1)*6; else if (m2 < m1) time = time + (m1-m2)*4; m1 = m2; } cout << time + n*5<<endl; } }
水题,一次AC