PAT 甲级 1008 Elevator (20)(20 分)模拟水题
题目翻译:
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 分)模拟水题的更多相关文章
- PAT 甲级 1008 Elevator (20)(代码)
1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...
- PAT 甲级 1008 Elevator
https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016 The highest building i ...
- PAT甲级——1008 Elevator
PATA1008 Elevator The highest building in our city has only one elevator. A request list is made up ...
- pat 1008 Elevator(20 分)
1008 Elevator(20 分) The highest building in our city has only one elevator. A request list is made u ...
- 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 ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- 1008 Elevator (20 分)(模拟)
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- PAT 甲级 1016 Phone Bills (25 分) (结构体排序,模拟题,巧妙算时间,坑点太多,debug了好久)
1016 Phone Bills (25 分) A long-distance telephone company charges its customers by the following r ...
随机推荐
- 框架-springmvc源码分析(二)
框架-springmvc源码分析(二) 参考: http://www.cnblogs.com/leftthen/p/5207787.html http://www.cnblogs.com/leftth ...
- eclipse中导入maven项目:org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.Maven
org.codehaus.plexus.archiver.jar.Manifest.write(java.io.PrintWriter) 解决方法为:更新eclipse中的maven插件 1.help ...
- [翻译]将智能指针用于C++的类成员
http://stackoverflow.com/questions/15648844/using-smart-pointers-for-class-members Question: I'm hav ...
- ResourceNotFound: rosbridge_server
Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking ...
- Java线程池Executor使用
合理利用线程池能够带来三个好处.第一:降低资源消耗.通过重复利用已创建的线程降低线程创建和销毁造成的消耗.第二:减少系统对于,外部 服务的响应时间的等待.第三:提高线程的可管理性.线程是稀缺资源,如果 ...
- CSS之旋转立方体
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- RabbitMQ 消息传递的可靠性
生产者保证消息可靠投递 消费者保证消息可靠消费 RabbitMQ持久化 参考:https://blog.csdn.net/RobertoHuang/article/details/79605185
- Rails 5 Test Prescriptions 第7章 double stub mock
https://relishapp.com/rspec/rspec-mocks/v/3-7/docs/basics/test-doubles 你有一个问题,如果想为程序添加一个信用卡程序用于自己挣钱. ...
- 使用POI导入小数变成浮点数异常
例如 我在Excel中的数据为17.2, 导入到表中就变成了17.1999999或者17.20000001 原因是我用double接收了17.2,然后直接用了String去转换,精度就丢失了. 代 ...
- Swagger使用总结(十九)
1. Swagger是什么? Swagger 是一款RESTFUL接口的文档在线自动生成+功能测试功能软件. 官方说法:Swagger是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTfu ...