HDU--Elevator(水题)
Elevator
Time Limit: 1000ms Memory limit: 32768K 有疑问?点这里^_^
题目描写叙述
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.
输入
输出
演示样例输入
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(水题)的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5038 水题 可是题意坑
http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数 这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心 If not all ...
- hdu 5138(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5138 反着来. #include<iostream> #include<cstdi ...
随机推荐
- 关于css优先级
css的优先级从低到高依次是:内部样式表的优先级为(1,0,0,0),id选择器优先级为(0,1,0,0),class选择器为(0.0,1,0),tag标签为(0.0,0,1).除此之外,!impor ...
- Cflow使用具体解释
近期使用cflow,依据Cflow提供的帮助对cflow的使用方法做了具体的整理.把经常使用的命令的使用方法贴出来.完整版请见http://download.csdn.net/detail/hanch ...
- 自定义cas客户端核心过滤器AuthenticationFilter
关于cas客户端的基本配置这里就不多说了,不清楚的可以参考上一篇博文:配置简单cas客户端.这里是关于cas客户端实现动态配置认证需要开发说明. 往往业务系统中有些模块或功能是可以不需要登录就可以访问 ...
- CSS 杂记
1. z-index: img{ position:absolute; left:0px; top:0px; z-index:-1;} 所有主流浏览器都支持 z-index 属性. 注释:任何的版本的 ...
- JSP的页面连接和提交方式(web基础学习笔记六)
一.GET请求新页面 1.1.超链接请求新页面 <!-- 超链接到page2 --> <a href="page2.jsp">链接到page2</a& ...
- 二叉查找树实现实例(C语言)
/* search_tree.h */ #ifndef _SEARCH_TREE_H #define _SEARCH_TREE_H struct tree_node; typedef struct t ...
- SSH框架学习
首先,SSH不是一个框架,而是多个框架(struts+spring+hibernate)的集成,是目前较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层Web应用程序. 集成SSH框 ...
- cookie 设置有效期 检测cookie
设置cookie 函数直接上代码: function setCookie(name, value, days) { //设置cookie var d = new Date(); d.setTime(d ...
- linux软硬链接
ln分为软链接和硬链接 1.软连接 -s ln -s /mnt/hgfs/SHARE hvshare2 相当于在当前目录下新建一个名为hvshare2的快捷方式指向/mnt/hgfs/SHARE路 ...
- fdisk -l解析
fdisk -l显示信息详解 [root@www.linuxidc.com ~]# fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 hea ...