1008. Elevator (20)
来源:互联网 发布:php sql注入漏洞 编辑:程序博客网 时间:2024/06/12 18:10
1008. Elevator (20)
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
题意:
给出乘梯者按电梯的层数,求电梯运行总时间
题解:
直接模拟
#include <iostream>using namespace std;int main(){ int n, now, last, sum; cin >> n; now = 0; sum = 0; for(int i = 0; i < n; i++){ last = now; cin >> now; if(now > last) sum += (now - last) * 6 + 5; else sum += (last - now) * 4 + 5; } cout << sum << endl; //system("pause");}
- 1008. Elevator (20)
- 1008. Elevator (20)-PAT
- 【PAT】1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- PAT 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- PAT 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- 1008. Elevator (20)
- ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist的原因分析
- 【making tools】:获得10000个随机密码
- 快速创建数组
- hiho一下 第八十八周
- ubuntu下利用gcc编译C语言程序
- 1008. Elevator (20)
- CGRect转为string
- 4. PathVariable、RequestParam、 CookieValue、SessionAttributes、ResponseBody、RequestHeader注解类
- 链表功能的增加
- 这两天做leetcode的心得
- LeetCode 2016 282,241
- Leetcode:26. Remove Duplicates from Sorted Array(JAVA)
- 在Android开发中遇到java.lang.NoClassDefFoundError的一般解决办法
- UDP是什么、及UDP和TCP的区别?