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<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std; int a[10004]; int main()
{
int n;
scanf("%d",&n);
for(int i=1; i<=n; i++)
{
scanf("%d",&a[i]);
}
a[0]=0;
int t=0;
for(int i=0;i<n;i++)
{
if(a[i+1]>a[i])
{
t+=(a[i+1]-a[i])*6;
}
else if(a[i+1]<a[i])
{
t+=(a[i]-a[i+1])*4;
}
}
t+=n*5;
printf("%d\n",t);
return 0;
}

最新文章

  1. [PHP源码阅读]count函数
  2. input 栏位光标末尾闪烁
  3. 使用nodejs+express+socketio+mysql搭建聊天室
  4. 数据结构和算法 &ndash; 12.高级查找算法(下)
  5. CF 600B Queries about less or equal elements --- 二分查找
  6. react webpack.config.js 入门学习
  7. Android布局_帧布局FrameLayout
  8. FDR
  9. JDBC中DAO事务函数模版
  10. Java操作Hbase进行建表、删表以及对数据进行增删改查,条件查询
  11. ASP实现清除HTML标签,清除&amp;nbsp;空格等编码
  12. HTTP Content-type 对照表
  13. 王立平-NGUI
  14. Android的JunitTest
  15. 50个Java多线程面试题(上)
  16. 使用 LVS 实现负载均衡原理及安装配置详解
  17. Uva - 804 - Petri Net Simulation
  18. 11.4、Libgdx的音频之录制PCM音效
  19. 169. Majority Element求众数
  20. 奇偶个数-java

热门文章

  1. 机房servlet过滤器
  2. linux添加root级别账户
  3. 注释和取消注释 程序中的log日志
  4. mysql 用户及赋予权限
  5. Django入门-框架目录介绍
  6. HTML的基础知识
  7. 表单跳转到Struts2
  8. [leetcode]415. Add Strings字符串相加
  9. 11-简单解释spingmvc项目的结构
  10. ssh登录忽略known_hosts列表