1008. Elevator (20)

原创 2015年07月06日 21:16:07

1008. Elevator (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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 Specification:

Each input file contains one test case. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100.

Output Specification:

For each test case, print the total time on a single line.

Sample Input:
3 2 3 1
Sample Output:
41
#include<vector>
#include <sstream>
#include<cmath>
#include<iomanip>
#include<iostream>
#include <ctype.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
//1008. Elevator (20)
int main()
{
	int n;
	cin >> n;
	int nums[10000] = { 0 };
	for (int i = 0; i < n; i++)
	{
		cin >> nums[i];
	}
	int mintues = nums[0] * 6 + 5;//从最底层到第一个数对应的层数
	for (int i = 1; i < n; i++)
	{
		int minus = nums[i] - nums[i - 1];//计算差值,通过正负判断电梯是往上还是往下
		if (minus>0)
		{
			mintues += minus * 6 + 5;
		}
		else
		{
			mintues += abs(minus) * 4 + 5;
		}
	}
	cout << mintues;
	return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

1008. Elevator (20)

The highest building in our city has only one elevator. A request list is made up with N positive nu...

【PAT (Advanced Level)】1008. Elevator (20)

1008. Elevator (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B ...

HDU-1008-Elevator(Java版本+简单模拟+恶心水果)

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

HDU1008-Elevator

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

Problem-1008: Elevator

杭电1008题. /* =======================================================================================...

杭电 ACM 1008 Elevator

ACM HDU 1008 Elevator

[HDOJ 1008] Elevator (模拟题)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1008  这个题目的难点在于如何理解Sample Input里的两个数17和41 起初我没理解题目真...
  • ajioy
  • ajioy
  • 2012-03-04 21:18
  • 1771

【模拟】HDU 1008 Elevator【题解】

Elevator

hdu 1008(Elevator)

杭州电子科技大学(hdu)第1008号题(Elevator) 一个电梯往上一层要6秒,往下一层要4秒,每层停留5秒,电梯开始在0层,给你电梯总共运行次数n,后面的n个数为这n次分别到的层数,求运行时间...
  • xu_zh
  • xu_zh
  • 2015-07-26 20:44
  • 105

HDOJ 1008 Elevator

Problem Description The highest building in our city has only one elevator. A request list is made ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)