Elevator

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Problem Description

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

There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.

Output

Print the total time on a single line for each test case.

Sample Input

1 2

3 2 3 1

0

Sample Output

17

41

--------

分析:  一开始在0层,  上升一层6s,下降一层4s, 停的层等待5s

time=上升的楼层*6+下降的楼层*4+停顿次数*5

-----------------------

import java.util.Scanner;
public class Main { public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();
if(n==0)break;
int a[]=new int[n+1];
int sumup=0;
int sumdown=0;
for(int i=1;i<=n;i++)
{
a[i]=sc.nextInt();
if(a[i]>a[i-1]) sumup+=a[i]-a[i-1];
else sumdown+=a[i-1]-a[i];
}
System.out.println(sumup*6+sumdown*4+n*5); }
sc.close(); } }

1.2.1 Elevator的更多相关文章

  1. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  2. poj[2392]space elevator

    Description The cows are going to space! They plan to achieve orbit by building a sort of space elev ...

  3. Design Elevator

    From: https://discuss.leetcode.com/topic/89/write-elevator-program-using-event-driven-programming/9 ...

  4. PAT (Advanced Level) Practise:1008. Elevator

    [题目链接] The highest building in our city has only one elevator. A request list is made up with N posi ...

  5. Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]

    作业提交时间:10月9日上课前. Design and implement an Elevator Scheduler to aim for both correctness and performa ...

  6. POJ2392Space Elevator(贪心+背包)

    Space Elevator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9970   Accepted: 4738 De ...

  7. hdu 1008 Elevator

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description The hig ...

  8. 【ACM】HDU1008 Elevator 新手题前后不同的代码版本

    [前言] 很久没有纯粹的写写小代码,偶然想起要回炉再来,就去HDU随便选了个最基础的题,也不记得曾经AC过:最后吃惊的发现,思路完全不一样了,代码风格啥的也有不小的变化.希望是成长了一点点吧.后面定期 ...

  9. Elevator 分类: HDU 2015-06-19 21:52 13人阅读 评论(0) 收藏

    Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  10. 1008. Elevator (20)

    The highest building in our city has only one elevator. A request list is made up with N positive nu ...

随机推荐

  1. 【Mac常用shell】

    1. 杀掉占用某端口的进程: lsof -i:9000  ->  确认PID kill PID 2. 环境变量: 直接用{PATH}:路径 的办法,经常不好用,我的解决办法: vi ~/.bas ...

  2. Java 面向对象之继承和重写OverWrite,重写和重载的区别,抽象类

    01继承的概述 A:继承的概念 a:继承描述的是事物之间的所属关系,通过继承可以使多种事物之间形成一种关系体系 b:在Java中,类的继承是指在一个现有类的基础上去构建一个新的类,构建出来的新类被称作 ...

  3. java动态代理和cglib

    1.代理类可以分为两种. 静态代理:由程序员创建或特定工具自动生成源代码,再对其编译.在程序运行前,代理类的.class文件就已经存在了. 动态代理:在程序运行时,运用反射机制动态创建而成. 2.JD ...

  4. Cocoapods 报警告Automatically assigning platform ios with version 9.0 on target....

    Automatically assigning platform iOS with version 9.0 on target 你的工程名称 because no platform was speci ...

  5. ActivityGroup实现tab功能

    android.app包中含有一个ActivityGroup类,该类是Activity的容器,可以包含多个嵌套进来的 Activitys,这篇文章就是借助ActivityGroup可以嵌套Activi ...

  6. 【Jmeter】Linux(Mac)上使用最新版本Jmeter(5.0)做性能测试

    本文我们一起来学习在Linux(Mac)上利用Jmeter进行性能测试并生成测试报告的方法. 环境准备 JDK 访问这个地址 [JDK11.01],根据实际环境下载一个JDK. Jmeter Jmet ...

  7. 8天掌握EF的Code First开发

    C#高级知识点&(ABP框架理论学习高级篇)——白金版 http://www.cnblogs.com/farb/p/ABPAdvancedTheoryContent.html

  8. import 与 import static

    原文链接:https://www.geeksforgeeks.org/static-import-java/ java中的静态引用 直接解释 一般引入类的方式:import java.lang.Mat ...

  9. (GoRails )使用Vue.js制作拖拉list功能(v1-4) gem 'acts_as_list'(自动排列顺序)

    系列视频: use Vue.js to build the drag and drop support for the list themselves the cards that are under ...

  10. RMQ板子

    对于RMQ这种静态最值询问, 用线段树的话查询过慢, 一般用ST表预处理后O(1)查询, 下以最大值查询为例, 这里假定$n$不超过5e5 void init() { Log[0] = -1; REP ...