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. PHP PSR-4 Autoloader 自动加载(中文版)

    Autoloader 关键词 “必须”("MUST").“一定不可/一定不能”("MUST NOT").“需要”("REQUIRED"). ...

  2. ANDROID 开机启动VNC SERVER

    ANDROID 开机启动VNC SERVER 背景信息: 最近在做一个项目,在项目需求中有这么一项“要把VNC SERVER 添加到android里并让其开机自启动”.其实做这个项目也挺缚手缚脚的,因 ...

  3. ipad安装自制ipa

    自己用XCode写了个小程序,想打包成ipa安装在真机上,网上查了查: 1.将工程的编译版本设置为release(在edit scheme里): 2.build for Archiving(Produ ...

  4. JS函数的属性

    1.arguments.callee //经典的阶乘(递归)函数 function factorial(num) { if (num <= 1) { return 1; } else { ret ...

  5. QThread与其他线程间相互通信

    转载请注明链接与作者huihui1988 QThread的用法其实比较简单,只需要派生一个QThread的子类,实现其中的run虚函数就大功告成, 用的时候创建该类的实例,调用它的start方法即可. ...

  6. C# 内存泄露

    一.事件引起的内存泄露 1.不手动注销事件也不发生内存泄露的情况 我们经常会写EventHandler += AFunction; 如果没有手动注销这个Event handler类似:EventHan ...

  7. java 防止sql注入的方法(非原创)

      一.SQL注入简介       SQL注入是比较常见的网络攻击方式之一,它不是利用操作系统的BUG来实现攻击,而是针对程序员编程时的疏忽,通过SQL语句,实现无帐号登录,甚至篡改数据库. 二.SQ ...

  8. tr转换或删除字符

    字符处理命令:tr —— 转换或删除字符 逐个字符处理而不是处理单词的tr [OPTION]... SET1 [SET2]    -d: 删除出现在字符集中的所有字符 tr ab AB

  9. hdu 5625 Clarke and chemistry

    Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned i ...

  10. hdu 4355 Party All the Time(三分搜索)

    Problem Description In the Dark forest, there is a Fairy kingdom where all the spirits will go toget ...