1008. Elevator (20)

时间限制
400 ms

内存限制
65536 kB

代码长度限制
16000 B

判题程序
Standard

作者
CHEN, Yue

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 1

Sample Output:

41
/*************************************************************************> File Name: 1008.c> Author: YueBo> Mail: yuebowhu@163.com> Created Time: Sun 14 May 2017 08:15:38 AM CST************************************************************************/#include<stdio.h>
#define UPTIME 6
#define DOWNTIME 4
#define STAYTIME 5int main()
{int N, crnt_floor = 0, lst_floor = 0;int loopi;int diff;int sum = 0;scanf("%d", &N);for (loopi = 0; loopi < N; loopi++){scanf("%d", &crnt_floor);diff = crnt_floor - lst_floor;if (diff > 0)sum += UPTIME * diff; elsesum += DOWNTIME * diff * (-1);sum += STAYTIME;lst_floor = crnt_floor;}printf("%d\n", sum);return 0;
}

1008. Elevator (20)相关推荐

  1. 1008 Elevator (20 分)_13行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 The highest building in our city has only one elevator. A request ...

  2. 【PAT (Advanced Level) Practice】1008 Elevator (20 分)

    #include<iostream> #include<cstdio> #include<cstdlib> #include<string> #incl ...

  3. 1008 Elevator (20 分)【难度: 简单 / 知识点: 模拟】

    https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016 直接模拟即可. #include<bi ...

  4. 【PAT甲级 sc.nextInt()的使用】1008 Elevator (20 分) Java版 9/9通过

    题目 这题已经给了电梯到达每一层的顺序,不需要自己调度电梯. 是个水题. 坑 & 心得 测试用例1 51 88 35 28 15 62 61 78 89 36 58 95 95 28 94 3 ...

  5. PAT甲级1008 Elevator:[C++题解]模拟

    文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:统计上升次数.下降次数:停留次数就是n.然后算数即可. ac代码 #include<bits/stdc++.h> usin ...

  6. HDU.1008 Elevator

    文章目录 一.题目解读 1.原题 2.分类 3.题意 4.输入输出格式 5.数据范围 二.题解参考 1.总体思路 2.思路① (1).分析 (2).AC代码 三.评价与后话 1.评价 2.后话 一.题 ...

  7. HDU 1008 Elevator

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1008 纯水题,就是要注意即使下一站是同一楼层也要停5秒 贴上代码: 1 #include <io ...

  8. 1008 Elevator

    思路如下:用一个整型数组存楼层,0号元素为0(开始停在0层),每读入一个元素,和上一个比较,更大说明是上升,总时长加上楼层差*6,反之说明是下降,总时长加上楼层差*4.最后再管停留时间,也就是所有元素 ...

  9. A1008 Elevator (20分)

    #include<cstdio> #include<string> #include<iostream> #include<vector> #inclu ...

最新文章

  1. WINCE系统启动时是否clean boot
  2. 关于android ksoap获取失败的问题
  3. Java中文问题详解
  4. PMP之项目沟通管理
  5. linux在主函数中调用进程,linux 调用进程
  6. python md5加密_Python MD5加密实例详解
  7. 交叉编译出现skipping incompatible_交叉编译bluez-5.50
  8. 差点被开除:一次订单号重复的事故
  9. Vim插件(二) Buffers窗口
  10. apache common-chain 简单使用
  11. word中两个文档合并后如何标题序号不变
  12. 计算机的自动播放功能有什么用,禁用自动播放功能的几种方法
  13. 塞班系统更新服务器,塞班系统又更新了,又更新了,仿佛回到十年前!
  14. 【牛客】网易2018校招数据分析师笔试解析
  15. Sigfox获法国最大一笔VC投资,打造物联网自己的互联网
  16. java中.的意思_java中“:”的意思是什么?
  17. java 方法互斥_Java中的互斥方法执行
  18. PTA 最佳情侣身高差
  19. 辽宁启迪电商:拼多多提升店铺流量的几个技巧
  20. python文件处理,去除内含子,拼接外显子

热门文章

  1. 前端学习(807):简单数据类型传参
  2. 前端学习(580):打开开发者工具
  3. 前端学习(312):高度塌陷
  4. 第三十期:BAT 为什么都看上了重庆?
  5. java学习(48):带参带返回
  6. c#语言float转换int,C#Float表达式:将结果float转换为int时的奇怪行为
  7. CSS之REM和EM的区别
  8. JavaScript toLocaleString()时间转化为字符串
  9. 每日一学:如何转换png图片为jpg图片
  10. java jdbc6_Java学习-JDBC