hdu 1008 Elevator
来源:互联网 发布:php获取时间 编辑:程序博客网 时间:2024/06/05 18:30
Elevator
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 43057 Accepted Submission(s): 23627
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
题目大意:就是说现在有个升降机,上升一层就要花6秒时间,到了目标楼层后会停留5秒时间,下降一层要花4秒时间,你一开始现在在0层,OJ提供你楼层信息,你计算出整个过程所花费的时间。
#include <iostream>#include<stdio.h>using namespace std;int f[10001];int main(){ int n; int sum=0; f[0]=0; while(scanf("%d",&n) && n) { sum=0; for(int i=1;i<=n;i++) { scanf("%d",&f[i]); if(f[i]>f[i-1]) { sum+=(f[i]-f[i-1])*6+5; } else { sum+=(f[i-1]-f[i])*4+5; } } printf("%d\n",sum); } return 0;}
0 0
- HDU 1008 Elevator
- hdu 1008Elevator
- HDU 1008 Elevator
- HDU 1008 Elevator
- hdu 1008 elevator 水
- HDU 1008 Elevator
- Hdu 1008 - Elevator
- HDU 1008 Elevator
- HDU--1008--Elevator
- hdu 1008 Elevator
- HDU-1008 Elevator
- HDU 1008 Elevator
- hdu 1008 Elevator
- Hdu--1008--Elevator
- hdu 1008 Elevator
- hdu 1008 Elevator
- hdu-1008-Elevator
- hdu 1008 Elevator
- codeforces 453A Little Pony and Expected Maximum 最大值期望
- 第四章 树(二)
- SDL2.0+ffmpeg2.3
- HDU 3695 Computer Virus on Planet Pandora AC自动机
- 01背包使用滚动数组优化详细讲解
- hdu 1008 Elevator
- 为虚拟机硬盘扩容(Oracle VM VirtualBox)的方法啊
- 【翻译自mos文章】SGA_TARGET与SHMMAX的关系
- hihoCoder- Trie树
- 白书上的AC自动机模板
- hdu 1284 钱币兑换问题
- 寻找最大的K个数
- HDU 1010 Tempter of the Bone 深搜剪枝
- poj 2229 Sumsets(递推&整数划分变形)