1008 Elevator (20分)(一个字短!)

PAT甲级真题——1008 Elevator (20 分) 1008 Elevator (20 分) 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 ... 阅读详情

1008 Elevator (20分)

题目

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>
using namespace std;
int main() {
 	int n, a, s, b;
 	scanf("%d %d", &n, &a);
 	s = (a - 0) * 6;
 	s += n * 5;
 	while (--n > 0) {
  		scanf("%d", &b);
  		s += (b - a) > 0 ? (b - a) * 6 : (a - b) * 4;
  		a = b;
 	}
 	printf("%d", s);
 	return 0;
}
BALM2深度解析 | 港大MARS实验室如何用点簇革新激光BA? 本文深度解析了港大MARS实验室提出的BALM2方案如何通过点簇技术革新激光BA(Bundle Adjustment)处理。BALM2将点云数据聚合为点簇,显著提升计算效率,实测显示其计算耗时仅为传统方法的1/20。文章详细介绍了点簇的核心原理、二阶优化方法及与传统方法的性能对比,展示了其在激光SLAM领域的突破性应用。 阅读详情

相关推荐

用PyTorch和snnTorch库5分钟搞定一个脉冲神经网络(SNN)手写数字识别Demo

本文详细介绍了如何使用PyTorch和snnTorch库快速搭建一个脉冲神经网络(SNN)手写数字识别Demo。通过模拟生物神经元的脉冲发放机制,SNN在低功耗场景中展现出独特优势。文章涵盖环境配置、数据预处理、模型构建、训练评估全流程,并提供了性能优化技巧和常见问题解决方案,帮助开发者在5分钟内实现高效的SNN应用。

weixin_29300931的博客 393

1008 Elevator (20)(20 分)(甲级)

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 sec...

薄荷糖 611

GD32 TLI+IPA实战:5分钟搞定RGB888屏幕显示,并开启2D图形加速

本文详细介绍了如何使用GD32微控制器的TLI和IPA功能快速驱动RGB888屏幕并开启2D图形加速。通过硬件配置、时序设置和显存管理,开发者可以高效实现图形界面渲染,并利用IPA加速器提升性能,适用于嵌入式GUI开发等场景。

weixin_29163797的博客 232

1008 Elevator (20)(20 分)

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 sec...

码奴生来就只知道前进 610

LAMMPS实操系列(四): 高熵合金FCC-CoCrCuFeNi的退火模拟

我们对FCC-CoCrCuFeNi的退火模拟思路主要是,首先将材料以均匀的速率用100 ps从300 K升温至1000 K,然后在1000 K的温度下平衡100 ps,随后以均匀的速率用100 ps从1000 K降温至300 K,随后通过共轭梯度下降法做静力学结构优化得到退火后的结构。由于FCC-CoCrCuFeNi高熵合金被认为是潜在的工程结构材料[1],接下来我们将对退火前后的结构进行压缩模拟,对比退火前后FCC-CoCrCuFeNi高熵合金的力学性能变化,敬请各位读者关注我们的更新。

Ceshigo_CD的博客 4837

C++五子棋人机对战

使用C++,开发五子棋人机对战,快速提升C++项目开发能力。

程序员Rock的博客 5万+

(甲)1008 Elevator (20 分)

题目: 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 ...

titi2018815的博客 327

torch.nn.rnn实现循环神经网络

------------------------------------nn.rnn模型实现。#------------------------------------模型实现。#-----------------------------------训练模型。#-----------------------------------训练模型。#--------------------------------读取数据。实现循环神经网络,并在至少一个数据集上进行实验,从训练时间、预测精度、...

matlab_python22的博客 2974

1008. Elevator (20)(C++)

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 sec...

qq_41562704的博客 450

上位机图像处理和嵌入式模块部署(开篇)

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】 图像处理是现实生活当中很实用的一门技术。工业上一般采用的是机器视觉,以传统算法和光源控制为主,部分采用了深度学习技术。而生活当中,则主要以二维码识别、人脸识别、车牌识别和ocr识别为主,这中间深度学习与AI扮演了很重要的角色。过去,市场上的商业收费软件,主要还是以传统设备厂商提供的上位机软件为主,那这一部分是不是结合最新的npu技术,应该做出一些新的东西出来呢?

嵌入式-老费,一个分享专业嵌入式知识的blog 1337

Ultralytics YOLOv8 英伟达™ Jetson®处理器部署

英伟达™(NVIDIA®)Jetson 是一系列嵌入式计算板卡,旨在为边缘设备带来加速的 AI(人工智能)计算。这些小巧而功能强大的设备围绕英伟达™(NVIDIA®)的GPU架构打造,能够直接在设备上运行复杂的人工智能算法和深度学习模型,而无需依赖云计算资源。Jetson 板卡通常用于机器人、自动驾驶汽车、工业自动化和其他需要在本地以低延迟和高效率执行人工智能推理的应用中。此外,这些板卡基于 ARM64 架构,与传统 GPU 计算设备相比运行功耗更低。英伟达™(NVIDIA®)JetPack SDK。

机器人控制与仿真应用 3876

1008 Elevator (20分)

1008Elevator(20分) The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which floors the elevator will stop, in specified ...

路途遥远,初心难忘,道阻且长,愿君走出半生,归来仍是少年 299

遥感影像道路提取算法——SGCN

用于从高分辨率遥感图像(TGRS)中提取复杂环境中道路的分割深度可分离图卷积网络摘要:高分辨率遥感图像的道路信息在各个领域得到广泛应用,基于深度学习的方法有效地显示了较高的道路提取性能。然而,在高分辨率遥感图像中,检测柏油路封闭或树木覆盖的道路,仍存在一些挑战,限制了提取的准确性:1)道路之间的阶级内差异较大,城市物体,特别是道路和建筑物之间的阶级间差异不明显;2)被树木、阴影和建筑物遮挡的道路难以提取;3)道路缺乏高精度遥感数据集。

littleyy666的博客 3846

PAT练习题(甲级) 1008 Elevator (20分)(Java实现)

PAT练习题 1008 Elevator (20分)题干题意解题思路代码实现总结 题干 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

CoderHqf的博客 9677

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

1008 Elevator (20 分)

1008 Elevator (20 分) 题目大意: 电梯, 上一层需要6秒, 下一层需要4秒, 每一次停需要停5秒 分析: 水题…上的和下的秒数加起来,最后乘n个5就行了 AC代码: #include &lt;iostream&gt; using namespace std; int num[105]; int n,tmp,ans=0; int main(){ cin&gt;&gt;n;...

Fighting_Eagle的博客 515

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

PAT甲级 - 1008 Elevator (20 分)

题目链接:PAT甲级 - 1008 Elevator (20 分) 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,...

314

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

PAT (Advanced Level) 1008 Elevator (20 分) 【Python/C++】【模拟】

PAT (Advanced Level) 1008 Elevator (20 分) 注意:连续两个人都处于同一层,仍需要停留5秒。 Python: import sys str_in = input() a = [int(n) for n in str_in.split()] #print(a) n = int(a[0]) res = int(0) ans = int(0) for i in r...

Irish_Moonshine的博客 380

【PAT甲级】1008 Elevator (20 分)

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 o...

初见还是重逢的博客 346

PAT甲级1008 Elevator (20分)

PAT甲级1008 Elevator (20分) 题目: 题目分析:刚看到题目以为是道dp问题,但仔细一看,这。。。 直接看AC代码吧,小学数学问题。 AC代码附上: #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ ...

weixin_43795683的博客 213

PAT 1008 Elevator

PAT甲级1008题Elevator (20 分)题解。 原题链接 题目: 1008Elevator(20分) The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which...

theStrongestPit的博客 284

条件判断 1008 Elevator (20分)

1008 Elevator (20分) 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 o...

BLUEsang的博客 238

PAT甲级 1008 Elevator (20分)

1008 Elevator (20分) 思路分析:就是统计电梯运行时间,注意满足请求后是不需要返回一楼的。目标楼层比当前楼层高就是楼层差值乘以6,比当前楼层低就是楼层差值乘以四,最后加上电梯在每层的停留时间就可以了~ AC代码: #include<iostream> using namespace std; int main() { int n, temp, begin = 0, ...

weixin_43684054的博客 247

PAT A1008 Elevator (20 分)

PAT A1008题目思路初次提交结果 题目 PAT A1008 思路 在输入过程中边求时间即可 初次提交 #include<cstdio> #pragma warning(disable:4996) int main() { int n,temp=0,time=0; scanf("%d", &n); for (int i = 0; i < n; i++) { ...

TC的博客 320

PAT 甲级 1008 Elevator (20 分)(Java)

文章目录PAT 甲级 1008 Elevator (20 分)(Java)题目题意解读解法解法一 PAT 甲级 1008 Elevator (20 分)(Java) 题目 题目链接 题意解读 数学题,只需要注意不需要回到0层即可; 解法 解法一 import java.util.Scanner; public class Main_1008 { public static void main(String[] args) { Scanner sc = new Scanner(Sys

盼你到天明的博客 304

PTA(甲级)1008 Elevator (20分)

题目来源:PTA(甲级)1008 Elevator (20分) 题目描述: 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 st...

sinat_41835935的博客 296
上一篇: 1007 Maximum Subsequence Sum (25分)(一个字短!)
下一篇: 1009 Product of Polynomials (25分)(一个字短!)
大了七八个
博客等级 码龄8年 2粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值