# PAT 1008

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<iostream>
#include<string>
using namespace std;
#define max 100
#define upTime 6
#define downTime 4
#define stayTime 5
int main()
{
int i,j,n,a[max],interval,time=0;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
interval=a[0];
time=upTime*a[0]+stayTime;
for(i=1;i<n;i++)
{
interval=a[i]-a[i-1];
if(interval>0)
{
time+=(interval*upTime+stayTime);
}else{
time+=(interval*(-1)*downTime+stayTime);
}
}
cout<<time<<endl;
return 0;
}```

0 条评论

• ### PAT 1007

Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is...

• ### LinuxShell_commands

(标*号的可选掌握，其他为必须掌握) 一、File management: ls                      - list file to...

• ### 1002. A+B for Polynomials (25)

Each input file contains one test case. Each case occupies 2 lines, and each lin...

• ### DFS

Definition First, choosing a beginning point V and mark it as an already visited...

• ### WPF will break when an exception be throw in the StylusPlugIn

We can write a class that inherits the StylusPlugIn. And this class can get the ...

• ### uva----11729 Commando war (突击战争)

G Commando War Input: Standard Input Output: Standard Output “Wa...

• ### 学会在未知需求的情况下对车辆服务进行定价（CS GT）

车辆服务提供者根据用户对不同出发地和目的地的出行需求来确定服务价格，可能会有利可图。之前关于车辆服务空间定价的研究都是基于供应商知道用户需求的假设。在本文中，我...

• ### 在Mac下刻录光盘

在Mac下如何刻录光盘呢，在Spotlight中搜索了dvd、cd什么的，出来的程序基本上都不能刻录光盘，一时摸不着头脑。查了资料之后，才发现Mac的光盘刻录在...

• ### 研发：Idea工具因为版本工具设置问题，导致全是红色

I have the current status of my files in the folders coloured red/brown. I tried...

• ### 《CSS实战手册》（CSS: The Missing Manual）中文勘误列表

原文：They also disallow a number of once-popular properties like a link's target p...