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使用curl伪造IP地址和header信息

    curl虽然功能强大,但是只能伪造$_SERVER["HTTP_X_FORWARDED_FOR"],对于大多数IP地址检测程序来说,$_SERVER["REMOTE_AD ...

  2. awk之7 常用函数的解析

    1.区域获取 substr(区域f,起始位置n1,获取范围n2) 解析:获取某个区域f内,从起始位置n1开始算起的n2个字符组成的字符串.如果n2不存在,则返回从n1开始到区域结束的内容. 例子:获取 ...

  3. STM32工程中出现 error: A1163E: Unknown opcode R0, , expecting opcode or Macro错误分析及处理

    最近测试以前的一个程序,一般都是打开以前写的程序修改参数直接测试 但是发现以前的编译后出现错误. 奇怪了,以前的出现都是调试好了的啊,一般都是没有错误的,迅速找问题 跳转到错误代码行 代码区域 Hea ...

  4. BZOJ 2535 Plane 航空管制2

    http://www.lydsy.com/JudgeOnline/problem.php?id=2535 思路:对于1,我们只需要每个点比前驱大就可以了,然后满足尽量优. 对于第二问,我们先求出这个点 ...

  5. USB系列之五:用汇编实现的一些USB功能

    前面的USB系列一至四,实现了我们需要的一些USB功能,但都是用C语言的32位代码,之后我们插进了三篇关于DOS下设备驱动程序的文章,我们现在应该清楚,当我们要在DOS下写一个U盘的驱动时,最好使用汇 ...

  6. HtmlTextNode & HtmlCommentNode

    在HtmlAgilityPack里,HtmlTextNode对应的是文本节点.这是一个非常简单的一个类,方法和字段都比较少. 一.属性 override string InnerHtml { get; ...

  7. C# 语法技巧_三目运算_switch_case

    一.三目运算符 三目运算符的一种简便写法: bool b = str == "abc" ? false : true; 当是自身时,实际上别吝啬那一个括号,有一个括号,实际上更容易 ...

  8. java 下拉框级联及相关(转)

    ActionLintsner都实现此接口,其它监听器可以监听的事件都可以被它捕获 public interface ActionListener extends EventListenerThe li ...

  9. IOS 从Resource文件夹下Copy文件到沙盒

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.t ...

  10. Spring(三)——AOP

    AOP全名为Aspect-Oriented Programming,意思是面向横切面编程,前边我们有过介绍   面向横切面编程AOP的理解 ,我们通过这种编程思想很容易的扩展我们的应用程序. 一,如何 ...