博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU-1008
阅读量:5126 次
发布时间:2019-06-13

本文共 1552 字,大约阅读时间需要 5 分钟。

水题

 

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
1 #include
2 #include
3 #include
4 #include
5 using namespace std; 6 7 int main() 8 { 9 int n;10 while (cin>>n&&n&&n<100)11 {12 int T[10005];13 int i;14 for (i = 0; i
> T[i];17 if (T[i] >= 100) return 0;18 }19 int sum;20 sum = T[0] * 6 + 5;21 for (i = 0; i
T[i]) sum += (T[i + 1] - T[i]) * 6 + 5;24 if (T[i + 1]
View Code

 

转载于:https://www.cnblogs.com/yifangfengjing/p/4252497.html

你可能感兴趣的文章
下一代操作系统与软件
查看>>
【iOS越狱开发】如何将应用打包成.ipa文件
查看>>
[NOIP2013提高组] CODEVS 3287 火车运输(MST+LCA)
查看>>
Python IO模型
查看>>
DataGridView的行的字体颜色变化
查看>>
局域网内手机访问电脑网站注意几点
查看>>
[Serializable]的应用--注册码的生成,加密和验证
查看>>
Linux操作系统 和 Windows操作系统 的区别
查看>>
Android-多线程AsyncTask
查看>>
LeetCode【709. 转换成小写字母】
查看>>
如何在Access2007中使用日期类型查询数据
查看>>
CF992E Nastya and King-Shamans(线段树二分+思维)
查看>>
如果没有按照正常的先装iis后装.net的顺序,可以使用此命令重新注册一下:
查看>>
linux install ftp server
查看>>
嵌入式软件设计第8次实验报告
查看>>
算法和数据结构(三)
查看>>
Ubuntu下的eclipse安装subclipse遇到没有javahl的问题...(2天解决了)
查看>>
alter database databasename set single_user with rollback IMMEDIATE 不成功问题
查看>>
WCF揭秘——使用AJAX+WCF服务进行页面开发
查看>>
【题解】青蛙的约会
查看>>