hdoj1008
来源:互联网 发布:perl语言编程pdf 编辑:程序博客网 时间:2024/06/14 18:32
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.
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 23 2 3 10
Sample Output
1741
Author
ZHENG, Jianqiang
Source
ZJCPC2004
Recommend
JGShining
#include<stdio.h>int time;int n;int from;int to;int main(void){ while(scanf("%d",&n),n){ from=0; time=0; for(int i=0;i<n;i++){ scanf("%d",&to); if(to-from>0) time+=(to-from)*6+5; else time+=(from-to)*4+5; from=to; } printf("%d\n",time); } return 0;}
- HDOJ1008
- hdoj1008
- hdoj1008
- hdoj1008
- hdoj1008
- HDOJ1008
- hdoj1008
- HDOJ1008 Elevator
- HDOJ1008 Elevator
- HDOJ1008 Elevator
- hdoj1008(模拟题)
- hdoj1008简单题
- HDOJ1008(简单计数)
- hdoj1008解题报告
- hdoj1008 Elevator(简单运用队列)
- .Net反编译工具Reflector .
- oracle 数据备份服务器安装 之乱码篇
- Struts2中实现多文件上传于下载
- 详解java三目条件运算符
- android 关于特定短信电话拦截
- hdoj1008
- Per Pixel Lighting [Part 3]
- mysql 自动注册 ODBC
- wincap的学习总结01
- epoll服务器示例, 监听5000个端口, 使用线程池
- 通过Eclipse3.1以上启动Tomcat访问不到tomcat管理界面的问题
- [POJ] 3302 Subsequence
- Per Pixel Lighting [Part 4]
- 普瑞玛法则