题目翻译:

1008.电梯

在我们的城市里,最高的建筑物里只有一部电梯。有一份由N个正数组成的请求列表。这些数表示电梯将会以规定的顺序在哪些楼层停下。电梯升高一层需要6秒,下降一层需要4秒。每次停下电梯将花费5秒。

给你一个请求列表,你需要计算出完成列表里的请求总共花费的时间。一开始电梯在0层。当请求全部完成时,电梯不需要回到底层。

输入说明:

每个输入文件包含一个测试实例。每个实例包含一个正整数N,后面跟着N个数字。所有输入的数字小于100。

输出说明:

对于每个测试实例,在一行中输出总时间。

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
int n;
int a[];
while(cin>>n)
{
for(int i=;i<=n;i++)
{
cin>>a[i];
}
int s=;
a[]=;
for(int i=;i<=n;i++)
{
if(a[i]-a[i-]>=) s+=(a[i]-a[i-])*;
else
s+=(a[i]-a[i-])*(-);
}
s+=n*;
cout<<s<<endl; }
return ;
}

PAT 甲级 1008 Elevator (20)(20 分)模拟水题的更多相关文章

  1. PAT 甲级 1008 Elevator (20)(代码)

    1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...

  2. PAT 甲级 1008 Elevator

    https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016 The highest building i ...

  3. PAT甲级——1008 Elevator

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

  4. pat 1008 Elevator(20 分)

    1008 Elevator(20 分) The highest building in our city has only one elevator. A request list is made u ...

  5. PAT甲 1008. Elevator (20) 2016-09-09 23:00 22人阅读 评论(0) 收藏

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  6. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  7. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  8. 1008 Elevator (20 分)(模拟)

    The highest building in our city has only one elevator. A request list is made up with N positive nu ...

  9. PAT 甲级 1016 Phone Bills (25 分) (结构体排序,模拟题,巧妙算时间,坑点太多,debug了好久)

    1016 Phone Bills (25 分)   A long-distance telephone company charges its customers by the following r ...

随机推荐

  1. 创建maven或者Gradle项目的时候GroupId和ArtifactId以及Version是什么意思?

    GroupId 是项目组织的唯一标识符,在实际开发中对应JAVA的包的结构,就是main目录里java的目录结构,如 ‘com.itcast.demo’. ArtifactId是项目的唯一标识符,在实 ...

  2. mysql Alter 的问题

    转自:https://blog.csdn.net/c_enhui/article/details/50903351 -- 设置或删除列的默认值.该操作会直接修改.frm文件而不涉及表数据. 此操作很快 ...

  3. jenkins svn源码管理小记

    之前对Jenkins管理SVN源码的逻辑不太清楚,简单研究了一下.对于一般的开发通常会有以下三个环境: 1.svn服务器 2.Jenkins服务器 3.开发服务器(部署测试版web应用或者其他应用) ...

  4. 为CentOS 7配置静态IP地址及遇到的问题解决策略

    为CentOS 7配置静态IP地址及遇到的问题解决策略 1. 为CentOS 7配置静态IP地址的两种方法 (原文地址:http://www.linuxidc.com/Linux/2014-10/10 ...

  5. Facade(外观)

    意图: 为子系统中的一组接口提供一个一致的界面,Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 适用性: 当你要为一个复杂子系统提供一个简单接口时.子系统往往因为不断演化而变 ...

  6. JavaScript--语法2--语句结构

    JavaScript--语句结构 一.心得 判断的时候常量放左边java中switch只支持四种类型,javaScript是弱类型,所有的都支持. 显示方法: 77 // alert("x= ...

  7. mybatis之org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'time' in 'class java.lang.String'

    mybatis接口 List<String> getUsedCate(String time); 配置文件 <select id="getUsedCate" pa ...

  8. CentOS下安装Python-pip

    1.安装epel-release软件包:自动配置yum的软件仓库,弥补centos内容更新有时比较滞后或是一些扩展的源没有. yum -y install epel-release 2.安装pytho ...

  9. iOS UI-静态单元格与动态单元格

  10. 浅析promise

    Promise是一个构造函数,可以通过new 操作符获取一个promise对象,promise者,人如其名也.对,就是承诺.显示生活中,我们承诺别人一件事,一般会在将来某个时间兑现承诺.而 Promi ...