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 ...
随机推荐
- 0118——RTLabel和正则表达式
RTLabel和RegexKitLite都要导入第三方库 使用Regexkitlite库进行正则表达式的解析 1.库是使用MRR,如果在ARC工程里面使用这个类,必须在project->buil ...
- oc基础 不可变字符串的创建和使用
oc基础 不可变字符串的创建和使用 简介:下面都是字符串基本用法. 1.字符串的创建 //创建oc常量字符串 NSString *str=@"hello world!"; NSL ...
- JQuery阻止表单提交的方法总结 - 使用onsubmit()验证表单并阻止非法提交
方法1:<form onsubmit="javascript:confirm()"> 方法内返回false阻止表单提交 示例:代码检测textarea内填写的长度,未填 ...
- service2008 word 导入导出 配置问题
除了配置 com组件权限 64位系统还要加 下面的文件 C:\Windows\SysWOW64\config\systemprofile\Desktop C:\Windows\Temp 也要加权限
- 雅思创始人Keith Taylor谈英语学习
雅思创始人Keith Taylor谈英语学习 “要学的是信息,而不是语言” 我们要学习一个国家的语言就得知道这个国家的方方面面.要学习英语就得了解英美国家的社会.经济.人文.历史等各方面的信息. 大家 ...
- Qt Quick - 开启下一代交互动效原型设计(效果很美,相关系列博文)
http://blog.csdn.net/unixzii/article/details/46501265
- 2014第3周六升级win8.1
今天上班主要是沟通了一个需求,然后思考下实现方案并记录下要点,晚上没有加班就回来,把操作系统升级到了win8.1,升级的重要原因是,原来的win7时常会卡顿,并且开关机慢,还有上面装了很多无用的影响效 ...
- C语言随笔_类型声明
有位同学说,“老师,我运行如下代码,结果报错了” #include <iostream.h> int main(){ char c, int b; return 0; } 报错结果是 ...
- hdu 5627 Clarke and MST(最大 生成树)
Problem Description Clarke is a patient with multiple personality disorder. One day he turned into a ...
- JAVA常见异常集锦(持续更新)
No1:Nested in org.springframework.beans.factory.parsing.BeanDefinitionParsingException 2013-07-02 10 ...