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 ...
随机推荐
- respondsToSelector的相关使用
-(BOOL) isKindOfClass: classObj 用来判断是否是某个类或其子类的实例 -(BOOL) isMemberOfClass: classObj 用来判断是否是某个类的实例 -( ...
- Masonry的一些使用。
除了等距的有问题(懒得改了),其他用过挺正常的,我自己也是刚使用,有问题还请海涵. 地址:http://pan.baidu.com/s/1boyxu8Z
- CAN总线
1.CAN(controller area network) LAN(local area network)局域网 2.CAN等通信协议的开发,使多种LAN通过网关进行数据交换得以实现.如应用在汽车电 ...
- (转)最小二乘法拟合圆公式推导及vc实现[r]
(下文内容为转载,不过已经不清楚原创的是哪里了,特此说明) 转自: http://www.cnblogs.com/dotLive/archive/2006/10/09/524633.html 该网址下 ...
- JS多选日期
项目需要一个可以选择多个日期的日期选择框,从网上找到一个单选的选择框源码 (http://blog.5d.cn/user2/samuel/200503/61881.html),修改成可以多选. 使用方 ...
- JQuery easyui (2)Droppable(放置)组件
所谓放置,就是将一个物体放入一个物体内,当然对于easyui来说触发各种效果是必不可少的,同时这个组件也不会依赖于其他组件. Droppable的加载方式 1,class 加载 一直不太喜欢cl ...
- jquery append 动态添加的元素事件on 不起作用问题的解决
on方法中要先找到原选择器(如例.info),再找到动态添加的选择器(如列.delete). 不多说看成功代码(注意加粗加色): <!DOCTYPE html PUBLIC "-//W ...
- [Head First Python]4. summary
1- strip()方法可以从字符串去除不想要的空白符 (role, line_spoken) = each_line.split(":", 1) line_spoken = li ...
- shell脚本练习(autocert)
#!/bin/bash#By Spinestars#20131118 #name:ca_cert#certficate ca cd /etc/pki/CA/auto num=$RANDOM mv ./ ...
- 使用SC命令时注意事项
使用SC命令时注意事项[转] Windows 2003 Server存在一个sc命令,(好像Windows 2000/XP/NT都有这个.)该命令可以手工创建Windows服务(NT Service) ...