PAT 1008. Elevator (20)
来源:互联网 发布:淘宝怎么查历史最低价 编辑:程序博客网 时间:2024/06/05 14:51
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
题目意思:第个数输入1个n,然后跟着n个电梯要停的楼层,电梯从0层开始,上楼每层间隔6秒,下楼4秒,在每层要停5秒
#include<stdio.h>#include<math.h>#include<stdlib.h>using namespace std;int main(){ int n; while(~scanf("%d",&n)) { int sum=0; int t=0; while(n--) { int m; scanf("%d",&m); if(m>t)sum+=(m-t)*6; if(m<t)sum+=(t-m)*4; sum+=5; t=m; } printf("%d\n",sum); } return 0;}
- 1008. Elevator (20)-PAT
- 【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 A 1008. Elevator (20)
- PAT(A) - 1008. Elevator (20)
- PAT甲 1008. Elevator (20)
- 【PAT甲级】1008. Elevator (20)
- PAT A 1008. Elevator (20)
- PAT甲级1008. Elevator (20)
- PAT甲级1008. Elevator (20)
- PAT-A 1008. Elevator (20)
- pat甲级1008. Elevator (20)
- Android代码混淆之混淆规则
- 浅谈CSRF攻击方式
- css3实现鼠标移到图片上图片缓慢变大
- VMWare虚拟机提示:锁定文件失败,打不开磁盘的解决办法+查看虚拟机安装目录
- servlet和Spring的DispatcherServlet详解
- PAT 1008. Elevator (20)
- springmvc idea 运行 404
- my-mind在线思维导图软件
- ajax提交整个表单的快捷方式
- 河南工业大学2017“玲珑杯”程序设计竞赛 04
- IIC设备驱动程序(一)————IIC设备的总线及其协议
- HTTP Status 406 – Not Acceptable
- lintcode 375 克隆二叉树
- apply(对象,数组) ,call(对象,变量a,变量b)