PAT 1008 Elevator
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<bits/stdc++.h>
using namespace std;
typedef long long ll; int main(){
int n;
cin >> n;
int sum = n*;
int cur = ; for(int i=;i < n;i++){
int x; cin >> x;
int t = x-cur;
sum += (t>)?t*:(-t)*;
cur = x;
}
cout << sum; return ;
}
?这题也太水了吧
PAT 1008 Elevator的更多相关文章
- PAT 1008. Elevator (20)
1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...
- pat 1008 Elevator(20 分)
1008 Elevator(20 分) The highest building in our city has only one elevator. A request list is made u ...
- PAT 1008 Elevator 数学
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...
- PAT 甲级 1008 Elevator (20)(代码)
1008 Elevator (20)(20 分) The highest building in our city has only one elevator. A request list is m ...
- PAT甲 1008. Elevator (20) 2016-09-09 23:00 22人阅读 评论(0) 收藏
1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...
- 【PAT甲级】1008 Elevator (20分)
1008 Elevator 题目: The highest building in our city has only one elevator. A request list is made up ...
- PAT 1008
1008. Elevator (20) The highest building in our city has only one elevator. A request list is made u ...
- Problem : 1008 ( Elevator )
好操蛋啊,电梯竟然能原地不动,你大爷的,这逻辑,太弱智了.... Problem : 1008 ( Elevator ) Judge Status : Accepted RunId : 103 ...
随机推荐
- JavaWeb--简单分页技术
分页需要的技术点:1.前台分页标签的使用 2.前台上一页,下一页显示的业务逻辑 3.MSQL用到的语句 limit 4.封装pageBean对象 这个是PageBean用到的 分页公式: int t ...
- facebook api之Ad
Ad Contains information to display an ad and associate it an ad set. Each ad is associated with an a ...
- js旋转V字俄罗斯方块
实现效果如图,也就是一个图像的旋转.注意,旋转后的文字是相对应的,而且文字还是立起的.第一次点击时显示,第二次点击时开始旋转.下面是我做这个效果的记录,方法这么差,我也就不说什么了. 先上HTML/C ...
- python爬虫训练——爬poj题目
首先要解决的就是不同的题目在不同的页上,也就是要实现翻页功能,自动获取所要爬取的地址,通过分析可以得出不同的页面也就是volume=后面的数字不同 所以我们可以用re模块来替换即可: new_url ...
- HDU 1247 Hat’s Words(字典树)
http://acm.hdu.edu.cn/showproblem.php?pid=1247 题意: 给出一些单词,问哪些单词可以正好由其他的两个单词首尾相连而成. 思路: 先将所有单独插入字典树,然 ...
- BZOJ 1037: [ZJOI2008]生日聚会Party(区间dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1037 题意: 思路: 四维数组进行dp,dp[i][j][a][b]表示进行到第i个座位时已经有j个 ...
- 自定义标签TLD文件中,rtexprvalue子标签的意思
rtexprvalue的全称是 Run-time Expression Value, 它用于表示是否能够利用JSP表达式. 举例子: 1.定义一个TLD文件: <tag> <name ...
- 【Ruby】【基础】
# [Ruby 块]=begin1 块由大量代码构成2 块中代码包含在{}内3 从与其相同名称的函数调用4 可以使用yield语句调用块=enddef test p '在test方法内' yield ...
- MD5加密与Hash加密
一.Md5加密 MD5算法具有以下特点: 1.压缩性:任意长度的数据,算出的MD5值长度都是固定的. 2.容易计算:从原数据计算出MD5值很容易. 3.抗修改性:对原数据进行任何改动,哪怕只修改1个字 ...
- python requests post和get
import requests import time import hashlib import os import json from contextlib import closing impo ...