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 2
3 2 3 1
0

演示样例输出

17
41
水题。but坑了我一顿,本渣以为这电梯上到顶就会下来不在上去了呢。。

。

所以一開始开数组做的WA了
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdlib.h>
#include <vector>
using namespace std;
int main()
{
int n,i,start,x,sum;
while(cin>>n)
{
if(!n)break;
sum=0;start=0;
for(i=1;i<=n;i++)
{
cin>>x;
if(x>start) sum+=6*(x-start);
else sum+=4*(start-x);
sum+=5;
start=x;
}
cout<<sum<<endl;
}
return 0;
}

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. 搜狐视频Redis私有云平台CacheCloud

    一.CacheCloud是做什么的 CacheCloud提供一个Redis云管理平台:实现多种类型(Redis Standalone.Redis Sentinel.Redis Cluster)自动部署 ...

  2. Qtcreator中常用快捷键总结

    F1        查看帮助F2        跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2    声明和定义之间切换F4        头文件和源文件之间切换Ctrl+1     ...

  3. MySql无法远程登录以及IP被锁解决办法

    授权 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;Query OK, 0 rows aff ...

  4. 读取Mat文件中的汉字代码

    拿到一种元数据,格式为*.mat,但Access打不开,百度也没看到比较好的解决方案. 但是用文本文档可以打开,那估计它和txt类似了,于是想自己写代码来处理了,立马写了读取的丑陋工具.读取是没什么问 ...

  5. shapefile文件的符号化问题

    我们都知道,ArcGIS的shp文件只以坐标形式保存地图数据,地图的显示方法则是存储都数据库或地图文件(mxd)中,这一点是深信不疑的. 如果我们打开ArcMap,新建一个普通的地图文件(使用标准的模 ...

  6. 转:Tkinter教程之Text(2)篇

    '''Tkinter教程之Text(2)篇''''''6.使用tag来指定文本的属性'''#创建一个指定背景颜色的TAG# -*- coding: cp936 -*-from Tkinter impo ...

  7. ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

    Linux rpm方式安装完MySQL之后 mysql>SET PASSWORD = PASSWORD('newpasswd');

  8. axios 请求参数配置说明

    axios的配置项地址参考: https://www.npmjs.com/package/axios { // `url` is the server URL that will be used fo ...

  9. Protobuf学习 - 入门(转)

    从公司的项目源码中看到了这个东西,觉得挺好用的,写篇博客做下小总结.下面的操作以C++为编程语言,protoc的版本为libprotoc 3.2.0. 一.Protobuf? 1. 是什么?  Goo ...

  10. HDU 2795 Billboard (线段树)

    Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...