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

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int n,a[110],i,j,sum=0,t;
scanf("%d",&n);
a[0]=0;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]>a[i-1])
{
t=a[i]-a[i-1];
sum+=6*t;
}
else
{
t=a[i-1]-a[i];
sum+=4*t;
}
sum+=5;
}
printf("%d\n",sum);
return 0;
}

1008. Elevator (20)的更多相关文章

  1. PAT 1008. Elevator (20)

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  2. PAT 甲级 1008 Elevator (20)(代码)

    1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...

  3. PAT甲 1008. Elevator (20) 2016-09-09 23:00 22人阅读 评论(0) 收藏

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  4. 1008 Elevator (20分)

    1008 Elevator (20分) 题目: The highest building in our city has only one elevator. A request list is ma ...

  5. PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...

  6. 【PAT甲级】1008 Elevator (20分)

    1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...

  7. 1008 Elevator (20)(20 point(s))

    problem The highest building in our city has only one elevator. A request list is made up with N pos ...

  8. PAT 甲级 1008 Elevator (20)(20 分)模拟水题

    题目翻译: 1008.电梯 在我们的城市里,最高的建筑物里只有一部电梯.有一份由N个正数组成的请求列表.这些数表示电梯将会以规定的顺序在哪些楼层停下.电梯升高一层需要6秒,下降一层需要4秒.每次停下电 ...

  9. PAT Advanced 1008 Elevator (20 分)

    The highest building in our city has only one elevator. A request list is made up with N positive nu ...

随机推荐

  1. 使用 Environment Indicator 模块区分不同的 Drupal 环境

    每个 Drupal 网站建设人员到了某个时期,都会有误将线上站点当做本地站点进行修改的经历.尤其是在浏览器中打开了几十个页面时,很容易忘记究竟哪个是哪个. Environment Indicator ...

  2. windows bat 文件

    windows下的bat文件即批处理文件或批处理脚本,英文为BATCH,  BAT文件是无格式的文本文件. 在命令提示下键入批处理文件的名称,或者双击该批处理文件,系统就会调用Cmd.exe按照该文件 ...

  3. Sublime Text 2 配置及其使用

    如果说Notepad++是一款不错Code神器,那么Sublime Text应当称得上是神器滴哥. Sublime Text最大的优点就是跨平台,Mac和Windows均可完美使用:其次是强大的插件支 ...

  4. 【Hibernate 4】一对多映射配置

    一.一对多映射简介 建立一对多关系关系的表的原则是将一的一方的主键加入到多的一方的表作为外键.这里以学生和班级为例子来演示.以前不用hibernate时建立pojo类要在学生类Student中加入一个 ...

  5. keepalive实现web服务器active/passive

    https://github.com/acassen/keepalived/blob/v1.2.13/doc/keepalived.conf.SYNOPSIS http://ngyuki.hatena ...

  6. dell 网络产品线

    https://en.wikipedia.org/wiki/Dell_Networking_Operating_System http://topics-cdn.dell.com/pdf/ DNOS ...

  7. libpcap报文解析: ipv4、ipv6 @ 2014.7.2

    #include <string.h> #include <stdlib.h> #include <pcap.h> #include <stdio.h> ...

  8. kafka概念

    一.结构与概念解释 1.基础概念 topics: kafka通过topics维护各类信息. producer:发布消息到Kafka topic的进程. consumer:订阅kafka topic进程 ...

  9. hdu1150

    [ Reprinted ]最小点覆盖=最大二分匹配数 url: http://zhidao.baidu.com/link?url=ZMzk27V8P99KQN63DpVsE2fd1YBIk7Jg83E ...

  10. poj3692_Kindergarten

    这题目大意是:男孩互相认识,女孩互相认识,一部分男女之间认识,老师要选一部分人,要求这部分人必须都相互认识. 这是一个二部图,先求出补图,在补图中G‘左右两点有连线说明在G中两者不认识,反之成立. 所 ...