1008. Elevator (20)
时间限制400 ms
内存限制65536 kB
代码长度限制16000 B
判题程序Standard作者CHEN, Yue
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.
For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled.
Input Specification:
Each input file contains one test case. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100.
Output Specification:
For each test case, print the total time on a single line.
Sample Input:3 2 3 1Sample Output:41这题不用想太多,就是让你从0层爬到几层就爬到几层,向上爬一层用6秒,到目标层休息5秒,下一层4秒;问按要求总的要用多少时间。
评测结果
时间 结果 得分 题目 语言 用时(ms) 内存(kB) 用户 7月23日 22:04 答案正确 20 1008 C++ (g++ 4.7.2) 1 384 datrilla 测试点
测试点 结果 用时(ms) 内存(kB) 得分/满分 0 答案正确 1 252 1/1 1 答案正确 1 252 2/2 2 答案正确 1 348 2/2 3 答案正确 1 384 2/2 4 答案正确 1 384 2/2 5 答案正确 1 384 2/2 6 答案正确 1 180 2/2 7 答案正确 1 180 2/2 8 答案正确 1 300 2/2 9 答案正确 1 180 3/3
#include<iostream> using namespace std; int main() { int N, index,order,elevator; int up = 6, down = 4,total=5; cin >> N; total *= N; elevator = 0; for (index = 0; index < N; index++) { cin >> order; total = order > elevator ? total + (order - elevator)*up : total + (elevator - order)*down; elevator = order; } cout << total << endl; system("pause"); return 0; }