CDZSC_2015寒假新人(1)——基础 b
Description
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
Output
Sample Input
3 2 3 1
0
Sample Output
41
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
int n,N,m;
long long num;
while((scanf("%d",&N))&&N!=)
{
m=num=;
while(N--)
{
scanf("%d",&n);
if(m<n)
{
num+=*(n-m);
}
else
{
num+=*(m-n);
}
num+=;
m=n; }
printf("%lld\n",num);
}
}
CDZSC_2015寒假新人(1)——基础 b的更多相关文章
- CDZSC_2015寒假新人(1)——基础 i
Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...
- CDZSC_2015寒假新人(1)——基础 h
Description Ignatius was born in a leap year, so he want to know when he could hold his birthday par ...
- CDZSC_2015寒假新人(1)——基础 g
Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...
- CDZSC_2015寒假新人(1)——基础 f
Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u i ...
- CDZSC_2015寒假新人(1)——基础 e
Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever ...
- CDZSC_2015寒假新人(1)——基础 d
Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It i ...
- CDZSC_2015寒假新人(1)——基础 c
Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the wareho ...
- CDZSC_2015寒假新人(1)——基础 a
Description Contest time again! How excited it is to see balloons floating around. But to tell you a ...
- CDZSC_2015寒假新人(2)——数学 P
P - P Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
随机推荐
- (转) Overloads and templates
Overloaded functions In C++, two different functions can have the same name if their parameters are ...
- ERP行业推荐参考书籍
1 书名:<ERP 理论.方法与实践> 作者: 周玉清等编著 出版社:电子工业出版社 简介:本书全面介绍了ERP的基本原理和处理逻辑,以大量篇幅讨论了ERP的计划功能,特别是主生产计划功能 ...
- 修改Linux中的用户名
需要修改2个文件: /etc/hosts /etc/sysconfig/network 然后重启 1.修改/etc/sysconfig/network NETWORKING=yes HOSTNAME= ...
- struts2注解驱动 零配置
一.配置web.xml<filter><filter-name>struts2</filter-name><filter-class>org.apach ...
- ssh整合web.xml过滤器和监听器的配置 .
延迟加载过滤器 Hibernate 允许对关联对象.属性进行延迟加载,但是必须保证延迟加载的操作限于同一个 Hibernate Session 范围之内进行.如果 Service 层返回一个启用了延迟 ...
- 15个顶级Java多线程面试题及回答
Java 线程面试问题 在任何Java面试当中多线程和并发方面的问题都是必不可少的一部分.如果你想获得任何股票投资银行的前台资讯职位,那么你应该准备很多关于多线程 的问题.在投资银行业务中多线程和并发 ...
- php 去掉 头尾 空格 2种方法
看似很简单的问题,其实还是有点坑的,首先这里 空格转义,不是字符串,直接用trim()是去不掉. 1,用preg_replace替换 $test = " dfadad 论责民与三英的关系77 ...
- SQL Server索引语法 <第四篇>
从CREATE开始 通过显式的CREATE INDEX命令 在创建约束时作为隐含的对象 随约束创建的隐含索引 当向表中添加如下两种约束之一时,就会创建隐含索引. 主键约束(聚集索引) 唯一约束(唯一索 ...
- 扩展ArcGIS API for Silverlight/WPF 中的TextSymbol支持角度标注
原文 http://blog.csdn.net/esricd/article/details/7587136 在ArcGIS API for Silverlight/WPF中原版的TextSymbol ...
- 在WPF中使用ArcGIS Engine
原文 http://blog.csdn.net/zzahkj/article/details/9102621 1.首先,新建一个WPF项目,添加引用ESRI.ArcGIS.AxControls.ESR ...