1008. Elevator (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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>
#include<stack>
#include<cstring>
#include<iostream>
using namespace std;
int main(){
int n,b=,cur,t=;
scanf("%d",&n);
while(n--){
scanf("%d",&cur);
if(cur>b){
t+=(cur-b)*+;
}
else{
t+=(b-cur)*+;
}
b=cur;
}
printf("%d\n",t);
return ;
}

最新文章

  1. ASP.NET MVC4 URL传递汉字参数不能正确接收
  2. 简单粗暴,详细得不要不要的 JavaWeb快速入门实例(1)
  3. Fast and Robust Hand Tracking Using Detection-Guided Optimization
  4. Hibernate级联删除时:Cannot delete or update a parent row: a foreign key constraint fails异常
  5. 286. Walls and Gates
  6. Babel6.x 转换ES6
  7. bootstarp(carousel)组件
  8. redis内存管理代码的目光
  9. docker study
  10. 读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。 输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10的100次幂。 输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格。 输入样例: 1234567890987654321123456789 输出样例: yi san wu
  11. python数据库学习--Mysql
  12. MySQL之父造访腾讯云 为腾讯云数据库开源点赞
  13. sql server2005安装时报 ‘服务无法启动’
  14. 5.Django cookie
  15. Kali学习笔记17:OpenVAS安装部署
  16. DWT在栅格数据嵌入不可见水印的应用
  17. uboot 传递的参数 mtdparts
  18. 优化MVC,实现数据库表的记录的添加、删除、修改、查询。
  19. 《C语言程序设计》指针篇&lt;一&gt;
  20. 深入浅出理解 COOKIE MAPPING

热门文章

  1. [raspberry pi3] 安装ffmpeg
  2. C# console application executing macro function
  3. 从字符串中获取XML节点数据
  4. 教学ppt设计与制作
  5. Binder学习笔记(四)—— ServiceManager如何响应checkService请求
  6. luogu P3811线性求逆元
  7. LOJ2565 SDOI2018 旧试题 莫比乌斯反演、三元环计数
  8. StackOverflow
  9. CF1117G Recursive Queries
  10. [NodeJS]exit code