【c++】PAT (Advanced Level)1008. Elevator (20)
来源:互联网 发布:网络整合营销案例 编辑:程序博客网 时间:2024/06/04 19:28
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>#include <vector>using namespace std;int main() {int k;int totalTime=0;while(cin>>k){totalTime=k*5;int ele=0;while(k--){int a;cin>>a;if(a>ele){totalTime=totalTime+(a-ele)*6;ele=a;}else {totalTime=totalTime+(ele-a)*4;ele=a;}}cout<<totalTime;}return 0;}
- 【c++】PAT (Advanced Level)1008. Elevator (20)
- 【PAT Advanced Level】1008. Elevator (20)
- 【PAT (Advanced Level)】1008. Elevator (20)
- PAT (Advanced Level) Practise 1008. Elevator (20)
- 【PAT】【Advanced Level】1008. Elevator (20)
- PAT (Advanced Level) Practise 1008. Elevator (20)
- PAT(Advanced level) 1008. Elevator
- 1008. Elevator (20)——PAT (Advanced Level) Practise
- PAT (Advanced Level) 1008. Elevator (20) 解题报告
- [PAT (Advanced Level) ]1008. Elevator 解题文档
- 浙大 PAT Advanced level 1008. Elevator
- PAT (Advanced Level) Practise 1008 Elevator (20)
- PAT (Advanced) 1008. Elevator (20)
- PAT-PAT (Advanced Level) Practise 1008. Elevator (20) (简单模拟)【一星级】
- 浙大PAT (Advanced Level) Practise 1008 Elevator (20)
- PAT (Advanced Level) 1008. Elevator (20) 电梯总上升和下降次数
- Pat(Advanced Level)Practice--1008(Elevator)
- PAT (Advanced Level) Practise 1008 Elevator
- Mac 使用技巧收集
- java的技巧!
- UVa 146 - ID Codes
- Creating Hello World App Using Xcode 5 and Interface Builder
- POJ1502_MPI Maelstrom(Dijkstra)(floyd)
- 【c++】PAT (Advanced Level)1008. Elevator (20)
- 应收数据脚本
- Myeclipse配置maven环境
- 学习笔记----树状数组
- LINUX起源与发展
- YUV420p的数据想要在IOS中显示,转CIImage总是返回nil 问题未解决,这里记录下
- java的程序开源!
- JSPs实现复杂逻
- 统计数字问题