【题目链接】

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 <stdio.h>

 int main(void)
{
int N;
int i, pre, cur;
int delta;
int time; pre = ;
time = ;
scanf("%d", &N);
for(i = ; i < N; i++)
{
scanf("%d", &cur);
if(cur - pre >= )
{
delta = cur - pre;
time += (delta * );
}
else
{
delta = pre - cur;
time += (delta * );
}
pre = cur;
}
printf("%d", time + N * ); return ;
}

运行结果:

PAT (Advanced Level) Practise:1008. Elevator的更多相关文章

  1. PAT (Advanced Level) Practise:1002. A+B for Polynomials

    [题目链接] This time, you are supposed to find A+B where A and B are two polynomials. Input Each input f ...

  2. PAT (Advanced Level) Practise:1001. A+B Format

    [题目链接] Calculate a + b and output the sum in standard format -- that is, the digits must be separate ...

  3. PAT (Advanced Level) Practise:1027. Colors in Mars

    [题目链接] People in Mars represent the colors in their computers in a similar way as the Earth people. ...

  4. PAT (Basic Level) Practise:1008. 数组元素循环右移问题

    [题目连接] 一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A0A1……AN-1)变换为(AN-M …… A ...

  5. PAT (Basic Level) Practise:1040. 有几个PAT

    [题目链接] 字符串APPAPT中包含了两个单词“PAT”,其中第一个PAT是第2位(P),第4位(A),第6位(T):第二个PAT是第3位(P),第4位(A),第6位(T). 现给定字符串,问一共可 ...

  6. PAT (Advanced Level) Practise - 1094. The Largest Generation (25)

    http://www.patest.cn/contests/pat-a-practise/1094 A family hierarchy is usually presented by a pedig ...

  7. PAT (Basic Level) Practise:1032. 挖掘机技术哪家强

    [题目链接] 为了用事实说明挖掘机技术到底哪家强,PAT组织了一场挖掘机技能大赛.现请你根据比赛结果统计出技术最强的那个学校. 输入格式: 输入在第1行给出不超过105的正整数N,即参赛人数.随后N行 ...

  8. PAT (Advanced Level) Practise 1004 解题报告

    GitHub markdownPDF 问题描述 解题思路 代码 提交记录 问题描述 Counting Leaves (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 1600 ...

  9. PAT (Advanced Level) Practise - 1099. Build A Binary Search Tree (30)

    http://www.patest.cn/contests/pat-a-practise/1099 A Binary Search Tree (BST) is recursively defined ...

随机推荐

  1. HTML标签的应用(新手)

    雪碧图(精灵图): sprite compass-合并(尽量宽高相同) 兼容性: 1.resct重置技术:normalize技术 2.加前缀:-webkit- -moz- -0- -ms- 3.< ...

  2. Maven学习(五)-- 聚合与继承

    标签(空格分隔): 学习笔记 Maven的聚合特性能够把项目的各个模块聚合在一起构建: Maven的继承特性能够帮助抽取各模块相同的依赖和插件等配置,在简化POM的同时,还能够促进各个模块配置的一致性 ...

  3. Python进阶之“属性(property)”详解

    Python中有一个被称为属性函数(property)的小概念,它可以做一些有用的事情.在这篇文章中,我们将看到如何能做以下几点: 将类方法转换为只读属性 重新实现一个属性的setter和getter ...

  4. [转] 浅谈Linux系统的启动流程

    原文:http://blog.csdn.net/justdb/article/details/9621271 版权声明:本文为博主原创文章. Linux系统的启动时通过读取不同的配置文件,执行相应的S ...

  5. Action<>和Func<> 委托【代理】

    C#中的Action<>和Func<> 其实他们两个都是委托[代理]的简写形式. 一.[action<>]指定那些只有输入参数,没有返回值的委托 Delegate的 ...

  6. Windows 7 封装与定制不完全教程

    Windows 7 封装与定制不完全教程 从定制Win7母盘到封装详细教程 手把手教你定制WIN7小母盘 Windows 7 封装与定制不完全教程 [教程] Windows 7 封装与定制不完全教程( ...

  7. Unity中有两种Animation Clip

    http://blog.csdn.net/zzxiang1985/article/details/51291861 在Unity中,我们有两种方法创建Animation Clip. 一种(后面简称方法 ...

  8. org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter与org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  9. yii2-basic后台管理功能开发之一:引入模板

    前景:哎没想到用php的yii2框架写了官网……自己选择的框架,跪着也要码完,当年用yii2-basic搭建了官网,原是想偷懒的,没想到还要写后台.... 需求:实现一个可编辑页面图片及新闻内容的后台 ...

  10. WCF初探-1:认识WCF

    1.WCF是什么? WindowsCommunication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,它是.NET框架的一部分,由.NET Framework 3. ...