PAT甲级——1008 Elevator
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.
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 Specification:
Each input file contains one test case. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100.
Output Specification:
For each test case, print the total time on a single line.
Sample Input:
3 2 3 1
Sample Output:
41
#include<cstdio>
int main()
{
int stay=0,t;
int N,i,total=0;
scanf("%d",&N);
for(i=0;i<N;++i)
{
scanf("%d",&t);
if(t==stay)
{
total+=5;
continue;
}
if(t>stay)
total+=(t-stay)*6+5;
else
total+=(stay-t)*4+5;
stay=t;
}
printf("%d",total);
return 0;
}
PAT甲级——1008 Elevator的更多相关文章
- 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 (20)(20 分)模拟水题
题目翻译: 1008.电梯 在我们的城市里,最高的建筑物里只有一部电梯.有一份由N个正数组成的请求列表.这些数表示电梯将会以规定的顺序在哪些楼层停下.电梯升高一层需要6秒,下降一层需要4秒.每次停下电 ...
- PAT 甲级 1008 Elevator
https://pintia.cn/problem-sets/994805342720868352/problems/994805511923286016 The highest building i ...
- 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 ...
- PAT Advanced 1008 Elevator (20 分)
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- PAT甲级——A1008 Elevator
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- PAT Advanced 1008 Elevator (20) [数学问题-简单数学]
题目 The highest building in our city has only one elevator. A request list is made up with N positive ...
- PAT甲级1008水题飘过
题目分析:上去下来到达的时间和数量 #include<iostream> using namespace std; ]; int main(){ int n; while(scanf(&q ...
- 【PAT甲级】1008 Elevator (20分)
1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...
随机推荐
- 牛客——Rabbit的字符串
题目: 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 Rabbit得到了一个字符串,她的好朋 ...
- JavaScript 之 Function
JavaScript function 语句定义和用法: function 语句用于声明一个函数. 函数声明后,我们可以在需要的时候调用. 在 JavaScript 中,函数是对象,函数也有属性和方法 ...
- 未能加载文件或程序集“MySql.Data”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
未能加载文件或程序集“MySql.Data”或它的某一个依赖项.找到的程序集清单定义与程序集引用不匹配. (异常来自 HRESULT:0x80131040) 说明: 执行当前 Web 请求期间,出现未 ...
- 线段树--线段树【模板1】P3372
题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数加上x 2.求出某区间每一个数的和 输入格式 第一行包含两个整数N.M,分别表示该数列数字的个数和操作的总个数. 第二行包含 ...
- E - Tokitsukaze and Duel CodeForces - 1190C (博弈 + 窗体移动)
"Duel!" Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty ha ...
- cafe-ssd數據集訓練
训练方式::https://blog.csdn.net/xiao_lxl/article/details/79106837 caffe-ssd训练自己的数据集 https://blog.csdn.ne ...
- python format输出
http://www.cnblogs.com/nulige/p/6115793.html 2.Format 方式 [[fill]align][sign][#][0][width][,][.precis ...
- 对Java面向对象中多态的理解
理解的要点:多态意味着父亲的变量可以指向子类对象 面向对象程序设计的三大支柱是封装.继承和多态 封装对外把相应的属性和方法实现的细节进行了隐藏.继承关系使一个子类继承父亲的特征,并且加上了一些新的特征 ...
- 当初对"软件工程"这个专业的期待和想象是什么?
很多期待,很多幻想 印象很深刻的初中语文老师让我们背诵的一首诗<错误>: <错误> 作 者:郑愁予 我打江南走过 那等在季节里的容颜如莲花的开落 东风不来,三月的柳絮不飞 你底 ...
- IDA解析so文件异常(Binary data is incorrect maximum possible value is xx)
错误信息 Binary data is incorrect maximum possible value is 0 错误原因 so文件损坏 或者ida换成32 解决办法 重新获得so文件,或者调整id ...