PAT 甲级 1008. Elevator
来源:互联网 发布:软件购买合同 编辑:程序博客网 时间:2024/05/30 23:29
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;cin>>n;int now=0,next,sum=0;while(n--){cin>>next;if(now<next){sum=sum+(next-now)*6+5;}else{sum=sum+(now-next)*4+5;}now=next;}cout<<sum<<endl;}
- PAT 甲级 1008. Elevator
- [PAT-甲级]1008.Elevator
- PAT甲级1008. Elevator
- PAT 甲级 1008. Elevator
- 【PAT甲级】1008. Elevator (20)
- PAT甲级1008. Elevator (20)
- PAT甲级1008. Elevator (20)
- pat甲级1008. Elevator (20)
- PAT甲级 1008. Elevator (20)
- PAT甲级 1008. Elevator(20)
- PAT 甲级 1008. Elevator (20)
- PAT甲级1008. Elevator(20)
- PAT甲级1008. Elevator (20)
- 1008. Elevator (20)-PAT甲级真题
- 【PAT甲级】【C++】1008. Elevator (20)
- PAT TEST甲级1008. Elevator (20)
- PAT甲级练习1008. Elevator (20)
- PAT - 甲级 - 1008. Elevator (20)1008. Elevator (20)
- 关于easyUI登入界面不跳出当前tab
- Jenkins构建Python项目失败
- maven打包时跳过测试
- spoj2666 Qtree4(类似于bzoj1095: [ZJOI2007]Hide 捉迷藏)详解
- MOOC清华《面向对象程序设计》第4章:自动类型转换实验
- PAT 甲级 1008. Elevator
- 单例设计模式
- elasticsearch-php工具类的编写
- Java/Android 设计模式系列(7)--装饰者模式
- 《一个Android工程的从零开始》阶段总结与修改2-Retrofit 上传JSON及尾址特殊字符转译问题
- PAT 甲级 1009. Product of Polynomials
- STL例题
- Triple Generative Adversarial Nets
- javaseday30补充(uri url urlconnection )