Elevator

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30095 Accepted Submission(s): 16272

Problem Description

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

There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.

Output

Print the total time on a single line for each test case.

Sample Input

1 2
3 2 3 1
0

Sample Output

17
41

水题(话说有这么zz的电梯吗23333)

代码样例

#include <stdio.h>

int main() {

int t;

while (scanf("%d",&t) != EOF,t != 0) {

int time=0,temp=0;

for(int i=0; i < t; i++) {

int n;

scanf("%d",&n);

if(temp < n) {

time=time+(n-temp)6;

temp=n;

}

if(temp > n) {

time=time+(temp-n)
4;

temp=n;

}

if(temp == n)

time=time+5;

}

printf("%d\n",time);

}

return 0;

}

(补题 杭电 1008)Elevator的更多相关文章

  1. 杭电1008 Elevator

    #include <stdio.h> #include <stdlib.h> int main() { int n; int i,j; int num[101]; while( ...

  2. (杭电 2045)不容易系列之(3)—— LELE的RPG难题

    不容易系列之(3)-- LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...

  3. 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)

    以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...

  4. ZJUT11 多校赛补题记录

    牛客第一场 (通过)Integration (https://ac.nowcoder.com/acm/contest/881/B) (未补)Euclidean Distance (https://ac ...

  5. 杭电ACM题单

    杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最 ...

  6. 杭电ACM刷题(1):1002,A + B Problem II 标签: acmc语言 2017-05-07 15:35 139人阅读 评

    最近忙于考试复习,没有多少可供自己安排的时间,所以我利用复习之余的空闲时间去刷刷杭电acm的题目,也当对自己编程能力的锻炼吧. Problem Description I have a very si ...

  7. acm入门 杭电1001题 有关溢出的考虑

    最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...

  8. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

  9. 杭电ACM2076--夹角有多大(题目已修改,注意读题)

    杭电ACM2076--夹角有多大(题目已修改,注意读题) http://acm.hdu.edu.cn/showproblem.php?pid=2076 思路很简单.直接贴代码.过程分析有点耗时间. / ...

随机推荐

  1. 一、python小功能记录——监听键盘事件

    1.监听键盘按键 from pynput.keyboard import Listener def press(key): print(key.char) with Listener(on_press ...

  2. Windows下Git服务端和客户端的搭建

    1.服务器端的搭建 本人使用的是一款带源码的工具:bonobogitserver,对应的网址为:https://bonobogitserver.com/ 具体操作方式如下: 1.打开网址,下载最新版本 ...

  3. Mysql学习---使用Python执行存储过程

    使用Python执行存储过程 使用Python执行存储过程[2部分]: 1.执行存储过程,获取存储过程的结果集  2.将返回值设置给了  @_存储过程名_序号 = #!/usr/bin/env pyt ...

  4. Excel课程表

  5. August 31st 2017 Week 35th Thursday

    Whatever happened in the past is gone, the best is always yet to come. 无论过去发生什么,最好的永远尚未到来. Correct j ...

  6. Thinkphp 漏洞小试

    首先确定这个网站使用thinkphp的框架 国内很多php开源项目的代码都是使用thinkphp框架编写的,但是thinkphp框架有很多版本,如何才能知道我们使用的框架是哪个版本的呢? 在URL后面 ...

  7. webkit架构

    简要的说,WebKit由三个模块组成:JavaScriptCore.WebCore 和 WebKit.WebKit作为了整个项目的名称. JavaScriptCore:是JavaScript解释器: ...

  8. UVa 12661 - Funny Car Racing(Dijkstra)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  9. BZOJ2004:[HNOI2010]Bus 公交线路(状压DP,矩阵乘法)

    Description 小Z所在的城市有N个公交车站,排列在一条长(N-1)km的直线上,从左到右依次编号为1到N,相邻公交车站间的距离均为1km. 作为公交车线路的规划者,小Z调查了市民的需求,决定 ...

  10. 【[POI2014]HOT-Hotels】

    魏佬怒嘲我只会做给定一棵树,输出有多少个点这种问题 不过我连这个也不会做 还算一道不错的树上数数题目 但是我一直不会数数 求树上所有的三元组\((u,v,t)\),满足\(dis(u,v)=dis(u ...