被前两题虐身虐心后看到这题简直难以置信,怎么可以这么水!!一次AC不解释!!难道老师是故意放这么道水题来安慰我们受伤的小心灵??
Elevator
#include <iostream> using namespace std; int main() { int N,i,time; while(cin >> N) { if(N==0) break; else { int *q = new int[N+1]; for(i=1; i<=N; i++) cin >> q[i]; time = q[1]*6; if(N>=2) { for(i=2; i<=N; i++) { if(q[i]>q[i-1]) time += 6*(q[i]-q[i-1]); else if(q[i]<q[i-1]) time += 4*(q[i-1]-q[i]); } } time += 5*N; } cout << time << endl; } return 0; }