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. awk 提取数字

    echo b1c2d3d1e8f9 | awk ' { string=$0 len=length(string) for(i=0; i<=len; i++) { tmp=substr(strin ...

  2. servlet生命周期深入理解

    什么是Servlet Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HTTP 客户端的请求和 HTTP 服务器上的数据库或应用程序之间的中 ...

  3. MongoDB(课时4 数据增加)

    3.4 数据操作(重点) 只要是数据库就绝对离不开最核心的功能:CRUD(增加Create.读取查询Retrieve.更新Update.删除Delete),除了增加之外,其他都很麻烦,最麻烦的是修改. ...

  4. string_01

    内存释放和越界 越界:(1).复制越界,(2).取值越界 构造函数 (1).默认 空(无参) (2).拷贝(const string &) (3).带参数: const char * // Z ...

  5. [原][osg][gdal]两种方式修改tiff高程

    因为对于globalmap不熟悉,不怎么怎么修改高程,好像也没有这功能. 干脆自己手动修改了高程图tiff了 由于自身一直使用osg的 自己使用了osgDB直接读取tiff,修改后保存的. 同事小周一 ...

  6. 关于python中的 “ FileNotFoundError: [Errno 2] No such file or directory: '……'问题 ”

    今天在学python时,在模仿一个为图片加上图标并移动到指定文件夹的程序时遇到“FileNotFoundError: [Errno 2] No such file or directory: '152 ...

  7. Codeforces 96C - Hockey

    96C - Hockey 字符串处理 代码: #include<bits/stdc++.h> using namespace std; #define ll long long ; con ...

  8. angular5 表单元素 checkbox radio 组讲解

    一.checkedbox 1.ngModel绑定方式 <input [(ngModel)]="item.checked" value="item.checked&q ...

  9. 利用 AttachThreadInput 改变其它进程的输入法状态

    利用 AttachThreadInput 和 WM_INPUTLANGCHANGEREQUEST 消息 改变 其它 进程 的 输入 状态 ? 众所周知,通过 ActivateKeyboardLayou ...

  10. IDEA编译时出现"cannot resolve symbol"的问题时的解决方法。

    IDEA编译时出现cannot resolve symbol的报错时,(老表的问题出现在另一台电脑上,所以现在没办法给大家截图报错时的图,今天是周末没用那台电脑,突然想起来就想把它写下来,抱歉抱歉!! ...