杭电1008 £神魔★判官ぃ 2022-06-05 11:52 152阅读 0赞 # Elevator # **Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24941 Accepted Submission(s): 13418** Problem Description 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 There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed. Output Print the total time on a single line for each test case. Sample Input 1 2 3 2 3 1 0 Sample Output 17 41 //杭电1008 #include <iostream> using namespace std; int main (int argc, char **argv) { int num ; while (cin >> num && num != 0) { int a = 0, b = 0; int coast = 0; for (int i =0; i < num ; ++ i ) { cin >> b; if (b - a > 0) coast += 6 * (b -a) + 5; else coast += 4 * (a - b) + 5; a = b; } cout << coast << endl; } }
相关 杭电ACM基础题目(1000 1001 1004 1005 1008 1012 1014) 文章目录 1001、Sum Problem 1004、 Let the Ballon Rise 1005、 Number Sequ 心已赠人/ 2023年07月17日 06:43/ 0 赞/ 32 阅读
相关 杭电1061 Rightmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J 布满荆棘的人生/ 2022年09月17日 05:27/ 0 赞/ 282 阅读
相关 杭电1008-Elevator Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth 谁践踏了优雅/ 2022年08月08日 14:53/ 0 赞/ 184 阅读
相关 杭电1039 Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6553 一时失言乱红尘/ 2022年06月05日 12:48/ 0 赞/ 286 阅读
相关 杭电1008 Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth £神魔★判官ぃ/ 2022年06月05日 11:52/ 0 赞/ 153 阅读
相关 杭电1026 Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6553 快来打我*/ 2022年06月04日 05:53/ 0 赞/ 306 阅读
相关 杭电oj Problem Title 1 Pro. ID 1000 A+B Problem include<stdio.h> int main() { £神魔★判官ぃ/ 2022年05月15日 16:14/ 0 赞/ 334 阅读
相关 杭电2075 此题真的是简单的再不能简单了!呵呵!我一直纠结,出这样的题是什么意思呢?不懂!哎,不说那些废话了,直接 ac吧!呵呵! \include<iostream> using 今天药忘吃喽~/ 2021年12月01日 22:38/ 0 赞/ 310 阅读
相关 杭电2078 说实话,此题是一道有严重bug的问题,对于xhd没晚能复习的科目数m根本就没用上!!!哎不管那么些了,反正ac了!呵呵!此题这样想xhd得复习效率是前一课程和后一课程复习效率差 ╰+攻爆jí腚メ/ 2021年12月01日 22:38/ 0 赞/ 354 阅读
相关 杭电2090 此题就是一道令人无法琢磨的题!哎!!我简直就无语了!!呵呵!竟然能出这题。。。。 废话少说,直接ac!!! \\\ 此题要想输出结果,还需要注意一下! 在linux 约定不等于承诺〃/ 2021年12月01日 21:12/ 0 赞/ 368 阅读
还没有评论,来说两句吧...