简单模拟。

注意a[i]==a[i-1]的情况。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std; const int maxn=+;
int n,a[maxn]; int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%d",&a[i]);
a[]=;
int ans=;
for(int i=;i<=n;i++)
{
if(a[i]>a[i-]) ans=ans+(a[i]-a[i-])*,ans=ans+;
else if(a[i]<a[i-]) ans=ans+(a[i-]-a[i])*,ans=ans+;
else ans=ans+;
}
printf("%d\n",ans);
return ;
}

PAT (Advanced Level) 1008. Elevator (20)的更多相关文章

  1. 【PAT甲级】1008 Elevator (20分)

    1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...

  2. PTA (Advanced Level) 1008 Elevator

    Elevator The highest building in our city has only one elevator. A request list is made up with Npos ...

  3. PAT (Advanced Level) 1077. Kuchiguse (20)

    最长公共后缀.暴力. #include<cstdio> #include<cstring> #include<cmath> #include<vector&g ...

  4. PAT (Advanced Level) 1061. Dating (20)

    简单模拟. #include<stdio.h> #include<string.h> ],s2[],s3[],s4[]; ][]={"MON ", &quo ...

  5. PAT (Advanced Level) 1035. Password (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  6. 【PAT甲级】1008 Elevator (20 分)

    题意: 电梯初始状态停在第0层,给出电梯要接人的层数和层序号,计算接到所有人需要的时间,接完人后电梯无需回到1层(1层不是0层).电梯上升一层需要6秒,下降一层需要4秒,接人停留时间为5秒. AAAA ...

  7. PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...

  8. PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1046 Shortest Distance (20 分) 凌宸1642 题目描述: The task is really simple: ...

  9. PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...

随机推荐

  1. textFiled输入字数的控制问题之—把带输入的拼音也判断了

    一个textFiled,控制只能输入五个字,现在你已经输入了四个字,在输入第五个字的时候,输入一个拼音之后就不能输入后一个拼音,这里把拼音也当成字来判断了,这种情况下就需要_textFiled.mar ...

  2. iOS \'The sandbox is not sync with the Podfile.lock\'问题解决

    iOS \'The sandbox is not sync with the Podfile.lock\'问题解决 HUANGDI 发表于 2015-02-27 09:51:13 问题描述: gith ...

  3. SCP测试服务器的上行/下行带宽

    SCP测试服务器的上行/下行带宽,这个咋弄呢?有时间再研究一下.

  4. dsplay:table页面合并表格

    在实际项目中经常会遇到合并表格的情形,现在我将自己合并的方法写出来,供大家教参一下,顺便自己也作个备忘. <%@ page language="java" contentTy ...

  5. Bill Total Value

    Bill Total Value time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  6. PHP生成静态页面详解

    PHP生成静态页面详解 看到很多朋友在各个地方发帖问PHP生成静态文章系统的方法,以前曾做过这样一个系统,遂谈些看法,以供各位参考.好了,我们先回顾一些基本的概念. 一,PHP脚本与动态页面. PHP ...

  7. CSS3边框

    border-radius box-shadow border-image border-radius可以创建圆形,如果一个元素是正方形,则设置border-radius为边长,则为圆形 box-sh ...

  8. HDU 5723 Abandoned country

    题目说每条边权值都不一样,说明最小生成树是唯一的,不存在最小期望这一说. 然后就是先求出最小生成树,随便确定一个根节点,计算出每个点的子树有多少节点,记为c[x]. 指向x的这条边被统计的次数为c[x ...

  9. windows下spark开发环境配置

    http://www.cnblogs.com/davidwang456/p/5032766.html windows下spark开发环境配置 --本篇随笔由同事葛同学提供. windows下spark ...

  10. Html基础详解之(jquery)之二

    on(events,[selector],[data],fn) 在选择元素上绑定一个或多个事件的事件处理函数.on()方法绑定时间处理程序到当前选定的jQuery对象中的元素.在jQuery 1.7中 ...