1008. Elevator (20)
来源:互联网 发布:按键精灵节奏大师源码 编辑:程序博客网 时间:2024/06/05 10:38
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 i,N,Prefloor=0,Time=0;int c[100];cin>>N;for(i=0;i<N;i++){cin>>c[i];if(c[i]>Prefloor)Time+=6*(c[i]-Prefloor);if(c[i]<Prefloor)Time+=4*(Prefloor-c[i]);Prefloor=c[i];Time+=5;}cout<<Time<<endl;return 0;}
- 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)
- api
- DATABASE
- 页面URL设置
- 轻松搞定面试中的链表题目
- HDU 2045--不容易系列之(3)—— LELE的RPG难题【递推】
- 1008. Elevator (20)
- 矩阵相乘的优化
- GSM压缩/ 解压实现
- Linux 开机启动websphere 服务
- 林达华推荐的几本数学书
- 黑马程序员——OC基础—-----一个简单OC程序的分析
- 如何在多台机器上共享IOS证书
- ERROR:C++ 字符指针引起的段错误
- 2015.03.04学习笔记