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
 #include<stdio.h>/*一道水题,秒杀*/
int main()
{
int N;
while(scanf("%d",&N)==)
{
if(N==)
break;
int a[],i,j,time=,k;
a[]=;
for(i=;i<=N;i++)
scanf("%d",&a[i]);
for(i=;i<=N;i++)
time+=(a[i]-a[i-]>?(a[i]-a[i-])*:(a[i-]-a[i])*)+;
printf("%d\n",time);
}
}

Elevator(hdoj 1008)的更多相关文章

  1. pat 1008 Elevator(20 分)

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

  2. 贪婪大陆(cogs 1008)

    [题目描述] 面对蚂蚁们的疯狂进攻,小FF的Tower defense宣告失败……人类被蚂蚁们逼到了Greed Island上的一个海湾.现在,小FF的后方是一望无际的大海,前方是变异了的超级蚂蚁. ...

  3. 1008 Elevator (20 分)(模拟)

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

  4. 最小生成树(HDOJ 1863)

    畅通工程 http://acm.hdu.edu.cn/showproblem.php?pid=1863 1.Prim算法: Prim算法是由一个点(最初的集合)向外延伸,找到与集合相连权值最小的边, ...

  5. friend(hdoj 1719)

    Friend Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  6. 并查集(HDOJ 1856)

    并查集   英文:Disjoint Set,即“不相交集合” 将编号分别为1…N的N个对象划分为不相交集合, 在每个集合中,选择其中某个元素代表所在集合. 常见两种操作: n       合并两个集合 ...

  7. A - Space Elevator(动态规划专项)

    A - Space Elevator Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  8. poj2392 Space Elevator(多重背包问题)

    Space Elevator   Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8569   Accepted: 4052 ...

  9. POJ 2392 Space Elevator(多重背包)

    显然塔的总高度不会超过最大的a[i],而a[i]之前的可以到达的高度 是由a值更小的块组成,所以按照a从小到大的顺序去转移. 然后就是多重背包判断存在性了,几乎和coin那题一样. 数据没coin丧病 ...

随机推荐

  1. oracle的nvl和sql server的isnull函数

    最近公司在做Oracle数据库相关产品,在这里作以小结: ISNULL()函数 语法     ISNULL ( check_expression , replacement_value)  参数    ...

  2. ZendFramework 两种安装方式

    1. 在线安装(基于composer) Zend 应用程序骨架 GitHub 地址: https://github.com/zendframework/ZendSkeletonApplication ...

  3. 一级域名301重定向到www二级域名

    301重定向有利于百度的搜索 例如一个域名 www.test.com如果不做设置会产生4个网址, (1)test.com(2)www.test.com(3)test.com/default.html( ...

  4. numpy库:常用基本

    numpy 本文主要列出numpy模块常用方法 大部分内容来源于网络,而后经过自己的一点思考和总结,如果有侵权,请联系我 我是一名初学者,有哪些地方有错误请留言,我会及时更改的 创建矩阵(采用ndar ...

  5. node.js及相关组件安装

    第一步:下载安装文件(下载地址:官网http://www.nodejs.org/download/ )第二步:安装nodejs(双击直接安装) 安装完成后使用命令行查看版本信息,出现版本号说明安装成功 ...

  6. HC-MAC: A Hardware-Constrained Cognitive MAC for Efficient Spectrum Management

    IEEE JOURNAL ON SELECTED AREAS IN COMMUNICATIONS, VOL. 26, NO. 1, JANUARY 2008 正如上篇文章提到的,这篇论文设计的Mac协 ...

  7. USB Mass Storage学习笔记-STM32+FLASH实现U盘

    一.内容概述  采用STM32内部自带USB控制器外加大页NAND FLASH K9F1G08U0A实现一个128M的U盘. 1.STM32的USB控制器 STM32F103的MCU自带USB从控制器 ...

  8. 报LinkageError的原因

    LinkageError是一个比较棘手的异常,准确的说它是一个Error而不是Exception.java api对它没有直接的解释,而是介绍了它的子类: Subclasses of LinkageE ...

  9. xargs mv命令使用方法:ls *.mp3 |xargs -i mv {} /tmp

    ls  *.mp3 |xargs -i  mv {} /tmp 或者 find . -name "*.mp3" -exec mv {} /tmp \;

  10. UESTC_Sea Base Exploration CDOJ 409

    When the scientists explore the sea base, they use a kind of auto mobile robot, which has the missio ...