Elevator

nid=24#time">

Time Limit: 1000ms   Memory limit: 32768K  有疑问?点这里^_^

题目描写叙述

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.

输入

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.

输出

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

演示样例输入

  1. 1 2
  2. 3 2 3 1
  3. 0

演示样例输出

  1. 17
  2. 41
  1. 水题。but坑了我一顿,本渣以为这电梯上到顶就会下来不在上去了呢。。
  2.  
  3.  
  4. 所以一開始开数组做的WA
  1. #include <iostream>
  2. #include <cstring>
  3. #include <algorithm>
  4. #include <stdlib.h>
  5. #include <vector>
  6. using namespace std;
  7. int main()
  8. {
  9.   int n,i,start,x,sum;
  10.   while(cin>>n)
  11.   {
  12.   	if(!n)break;
  13.   	sum=0;start=0;
  14.   	for(i=1;i<=n;i++)
  15. 	{
  16. 		cin>>x;
  17. 		if(x>start) sum+=6*(x-start);
  18. 		else sum+=4*(start-x);
  19. 		sum+=5;
  20. 		start=x;
  21. 	}
  22. 	cout<<sum<<endl;
  23.   }
  24.   return 0;
  25. }

HDU--Elevator(水题)的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  3. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  4. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  5. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  6. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  7. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  8. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  9. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

  10. hdu 5138(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5138 反着来. #include<iostream> #include<cstdi ...

随机推荐

  1. 敏捷开发方法XP的12个最佳实践

    极限编程(eXtreme Programming,简称XP)是一种轻量级.高效.低风险.柔性.可预测的.科学的软件开发方法,其特性包含在12个最佳实践中. 1.  计划游戏 ( Planning Ga ...

  2. Eclipse 创建文件快捷菜单、避免格式化时自动换行、.properties文件中文乱码、在线安装FreeMarker

    创建文件快捷菜单设置 打开窗口“Customize Perspective - Java EE”,切换选项卡到“Shortcuts”: 进行一下配置: “Generate”:如上图勾选方式 " ...

  3. listView/GridView getChild获取不到的解决方法

    在onCreate或onResume中调用了getChildAt()方法,这时候adapter中的Item还没有放入到AdapterView中去.... 解决方法,当activity获得焦点事件的时候 ...

  4. VM虚拟机启动报错Reason Failed to lock the file怎么办

    VMware启动报错Reason: Failed to lock the file的解决方法 症状:  启动VMware虚拟机的时候出现了Cannot open the disk '*.vmdk' o ...

  5. CATransition 动画处理视图切换

    一:引入包和头文件:   需要在frameworks中添加QuartzCore.framework 在接口程序中加上头文件   #import <QuartzCore/QuartzCore.h& ...

  6. Java监控工具

     1. jmap 查看heapdump 2. jstack         查看javacore 3.jps        列出jvm进程 4.jstatd      启动jvm监控服务.它是一个基于 ...

  7. [Python]网络爬虫(五):urllib2的使用细节与抓站技巧

    转自:http://blog.csdn.net/pleasecallmewhy/article/details/8925978 前面说到了urllib2的简单入门,下面整理了一部分urllib2的使用 ...

  8. Cocos2d-x3.0 iOS 一键编译多个target并打包ipa。

    1.编写app打包为ipa的 shell脚本.将以下代码保存为app2ipa.sh. #!/bin/sh m_appPath="" m_ipaPath="" m ...

  9. python学习笔记之函数(方法)

    def func(x): print 'x is', x x = 2 print 'Changed local x to', x x = 50 func(x) print 'x is still', ...

  10. Cocos2dx 学习记录 [2] 关于混合和高亮一些知识点的体会

    网上有一篇博客讲的是高亮的http://www.cnblogs.com/mrblue/p/3455775.html 就是这篇,尽管代码简单,但对于刚開始学习的人的我,看的还是有些吃力的,毕竟有些内容不 ...