Elevator

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 49406    Accepted Submission(s):
27244

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
 
#include<stdio.h>
int main()
{
int n,m,j,i,l,t,sum;
int a[110];
while(scanf("%d",&n)&&n!=0)
{
m=0;sum=0;
a[0]=0;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]>m) //上楼的情况
{
sum+=(a[i]-a[i-1])*6+5;
m=a[i];
}
else if(a[i]<m) //下楼的情况
{
sum+=(m-a[i])*4+5;
m=a[i];
}
else if(a[i]==m) //在相同楼层的问题
{
sum+=5;
m=a[i];
}
}
printf("%d\n",sum);
}
return 0;
}

  

hdoj 1008 Elevator的更多相关文章

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

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

  2. Hdoj 1008.Elevator 题解

    Problem Description The highest building in our city has only one elevator. A request list is made u ...

  3. Problem : 1008 ( Elevator )

    好操蛋啊,电梯竟然能原地不动,你大爷的,这逻辑,太弱智了.... Problem : 1008 ( Elevator )     Judge Status : Accepted RunId : 103 ...

  4. PAT 1008. Elevator (20)

    1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

  5. PAT 1008 Elevator

    1008 Elevator (20 分)   The highest building in our city has only one elevator. A request list is mad ...

  6. PAT 甲级 1008 Elevator (20)(代码)

    1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...

  7. 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 ...

  8. pat 1008 Elevator(20 分)

    1008 Elevator(20 分) The highest building in our city has only one elevator. A request list is made u ...

  9. 【PAT甲级】1008 Elevator (20分)

    1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...

随机推荐

  1. linux grep命令总结

    风生水起善战者,求之于势,不责于人,故能择人而任势. 博客园    首页    新随笔    联系    订阅    管理 posts - 791,  comments - 394,  trackba ...

  2. http://nxlhero.blog.51cto.com/962631/1666250?plg_nld=1&plg_uin=1&plg_auth=1&plg_nld=1&plg_usr=1&plg_vkey=1&plg_dev=1

    http://nxlhero.blog.51cto.com/962631/1666250?plg_nld=1&plg_uin=1&plg_auth=1&plg_nld=1&am ...

  3. C语言字节对齐

    转自:http://blog.csdn.net/21aspnet/article/details/6729724 文章最后本人做了一幅图,一看就明白了,这个问题网上讲的不少,但是都没有把问题说透. 一 ...

  4. fedora

    http://blog.chinaunix.net/uid-14735472-id-3486501.html 使用 http://blog.csdn.net/crystony/article/deta ...

  5. Microsoft.Data.ConnectionUI.DataConnectionDialog

    MicrosoftVisualStudio里面的资源之数据库连接配置 这个功能的实现主要是用了Microsoft.Data.ConnectionUI.dll和Microsoft.Data.Connec ...

  6. Android开发之动画(转)

    activity跳转的过渡效果,很漂亮,很全 注意,切换方法overridePendingTransition只能在startActivity和finish方法之后调用. 第一个参数为第一个Activ ...

  7. hdu 4502 吉哥系列故事——临时工计划(dp)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4502 思路:一个简单的dp ,比赛时没做出来呢..... d[i]代表 到第i天时的最大值 #includ ...

  8. bzoj1385: [Baltic2000]Division expression

    欧几里得算法.可以发现规律,a[2]作为分母,其他作为分子,必定是最好的选择.判断是否为整数即可. #include<cstdio> #include<cstring> #in ...

  9. ZJOI2010网络扩容

    无限orz hzwer神牛…… 第一问很简单,按数据建图,然后一遍最大流算法即可.     第二问则需要用最小费用最大流算法,主要是建图,那么可以从第一问的残留网络上继续建图,对残留网络上的每一条边建 ...

  10. 架构版本与 NuGet 的版本不兼容 解决方案

    VS的NuGet管理在大大提高了开发效率,一直都在使用但今天在遇到了一个问题,引用一个所需要的NuGet包VS缺提示如下错误