题目翻译:

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. springboot中websoket的使用

    知识点:springboot项目中,websoket实时推送技术的介绍与使用      一.双向通信 http协议通信只能由客户端发起请求,服务端返回查询结果,如果我们想定时获取服务端的状态变化,相对 ...

  2. Scikit-learn 库的使用

    1. 与文本处理相关的库 1. 对语料库提取特征词集合 from sklearn.feature_extraction.text import TfidfVectorizer, CountVector ...

  3. Eclipse插件Fat Jar

    1.安装 1)Eclipse在线更新方法 Help > Install New Software > Add, name:Fat Jar location:http://kurucz-gr ...

  4. c++ 判断容器是否为空

    #include <iostream> #include <vector> #include <string> using namespace std; int m ...

  5. 读写 Excel 工作表

    导入诸如 CSV 之类文本格式的数据的优点是不需要依靠某些特定软件来读取数据,并且文件具有可读性,即软件中性.然而,它的缺点也很明显——我们不能直接对文本编辑器中的数据执行计算操作,因为这些内容是纯文 ...

  6. Tensorboard 的使用笔记

    参考的教程: https://www.tensorflow.org/guide/summaries_and_tensorboard 遇到的错误: File "/usr/local/lib/p ...

  7. torchnet package (1)

    torchnet package (1) torchnet torchnet torchnet是用于torch的代码复用和模块化编程的框架,主要包含四个类 Dataset 以不同的方式对数据进行预处理 ...

  8. halcon之屌炸天的自标定(1)

      本次先对halcon的自标定做个整体介绍,了解屌炸天的自标定在实际应用中的应用与实现方法,具体的编程细节将在后续的文章中介绍. halcon提供了一种自标定的算子,它可以在不用标定板的情况下,标定 ...

  9. SharePoint 2013的100个新功能之网站管理(三)

    一:跨网站发布 跨网站发布是SharePoint 2013的一个新功能,可以使用户跨网站集.Web应用程序甚至是场重用内容.该功能叫做跨网站发布功能.用户可以使用该功能在SharePoint 2013 ...

  10. 响应: 500 OOPS: priv_sock_get_int 错误: 读取目录列表失败

    /************************************************************************* * 响应: 500 OOPS: priv_sock ...