(补题 杭电 1008)Elevator
Elevator
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30095 Accepted Submission(s): 16272
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.
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 2
3 2 3 1
0
Sample Output
17
41
水题(话说有这么zz的电梯吗23333)
代码样例
#include <stdio.h>
int main() {
int t;
while (scanf("%d",&t) != EOF,t != 0) {
int time=0,temp=0;
for(int i=0; i < t; i++) {
int n;
scanf("%d",&n);
if(temp < n) {
time=time+(n-temp)6;
temp=n;
}
if(temp > n) {
time=time+(temp-n)4;
temp=n;
}
if(temp == n)
time=time+5;
}
printf("%d\n",time);
}
return 0;
}
(补题 杭电 1008)Elevator的更多相关文章
- 杭电1008 Elevator
#include <stdio.h> #include <stdlib.h> int main() { int n; int i,j; int num[101]; while( ...
- (杭电 2045)不容易系列之(3)—— LELE的RPG难题
不容易系列之(3)-- LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)
以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...
- ZJUT11 多校赛补题记录
牛客第一场 (通过)Integration (https://ac.nowcoder.com/acm/contest/881/B) (未补)Euclidean Distance (https://ac ...
- 杭电ACM题单
杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最 ...
- 杭电ACM刷题(1):1002,A + B Problem II 标签: acmc语言 2017-05-07 15:35 139人阅读 评
最近忙于考试复习,没有多少可供自己安排的时间,所以我利用复习之余的空闲时间去刷刷杭电acm的题目,也当对自己编程能力的锻炼吧. Problem Description I have a very si ...
- acm入门 杭电1001题 有关溢出的考虑
最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...
- 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”
按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...
- 杭电ACM2076--夹角有多大(题目已修改,注意读题)
杭电ACM2076--夹角有多大(题目已修改,注意读题) http://acm.hdu.edu.cn/showproblem.php?pid=2076 思路很简单.直接贴代码.过程分析有点耗时间. / ...
随机推荐
- 中文乱码(Python、WEB、ajax)
http://my.oschina.net/leejun2005/blog/74430 #查看errorb是unicode,还是stringprint isinstance(errorb,unicod ...
- matlab 波纹扭曲
% 波纹扭曲 img=imread('pic.jpg'); img=im2double(img); [h,w,c]=size(img); ratio=600/(h+w); img=imresize(i ...
- 解决Could not commit JPA transaction RollbackException: Transaction marked as rollbackOnly
项目测试发生问题,方法正常结束,但是报了 Could not commit JPA transaction; nested exception is javax.persistence.Rollbac ...
- 浏览器相关--H5本地存储
因为项目需要,最近研究了一下HTML5本地存储相关的东西,在这简单的记录一下. 浏览器存储主要包括一下几个部分1. cookie2. localStorage3. sessionStorage4. i ...
- 阿里云服务器ECS LAMP环境安装(Ubuntu)
所周知如果要搭建一个网站lamp环境必不可少,但是阿里云初始的时候没有自带lamp环境,原本阿里云自带的包也已经失效了,所以需要自己来安装.但是网上大部分博客都有些老,于是中间遇到了一些小坑,今天就在 ...
- Client/Server 模型 与socket
Client/Server 模型 Sockets 是以 Client 和 Server 交互通信方式来使用的.典型的系统配置是把 Server 放在一台机器中,而把 Client 放在另一台机器中, ...
- 【LGP5162】WD与积木
题目 场面过度玄学,容易引起不适 我们发现我们要求的这个期望由分母和分子两部分构成 易发现 \[Ans=\frac{\sum_{i=1}^nS_2(n,i)\times i\times i!}{\su ...
- 1、Android-活动(下)
1.4.活动的生命周期 对于活动来说生命周期的理解时非常重要的 当对其生命周期有了足够的了解,可以很好的写出程序 1.4.1.返回栈 Android中的活动是可以层叠的 没启动一个新的活动,就会立即覆 ...
- WEB安全 魔术引号及注入类型
一.魔术引号 1. magic_quotes_gpc 变量 什么是魔术引号 Warning本特性已自 PHP 5.3.0 起废弃并将自 PHP 5.4.0 起移除.当打开时,所有的 '(单引号),&q ...
- Jenkins Gitlab持续集成打包平台搭建
http://www.cnblogs.com/skyseraph/p/5695021.html 1. 相关概念 Jenkins Jenkins,一个用Java编写的开源的持续集成工具,提供了软件开发的 ...