1008. Elevator (20)

本文介绍了一个电梯调度算法的具体实现过程,该算法通过计算不同楼层请求之间的移动时间和停靠时间来确定完成所有请求所需的总时间。输入包含一系列正数,每个数表示电梯需要停靠的楼层,输出则是完成这些请求所需的总时间。
  1. 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 <bits/stdc++.h>
using namespace std;
int s[1231];
int main()
{
  int n;
  scanf("%d", &n);
  for(int i=0;i<n;i++)
  {
    scanf("%d", &s[i]);
  }
  int k = 0;//记录当前的层数
  long long int ans = 0;//记录时间
  for(int i=0;i<n;i++)
  {
    if(k<s[i])//向上升
    {
      ans = ans + (s[i] - k) * 6 + 5;
      k = s[i];
    }
    else if(k>s[i])//要向下降
    {
       ans = ans + (k - s[i]) * 4 + 5;
       k = s[i];
    }
    else
    ans += 5;//原地不走时,要停留5s
  }
  printf("%lld\n", ans);
  return 0;
}
光伏储能虚拟同步发电机并网仿真模型(Simulink仿真实现)内容概要:本文介绍了基于Simulink的光伏储能虚拟同步发电机(VSG)并网仿真模型,旨在通过建立光伏发电系统与储能系统的集成模型,结合虚拟同步发电机技术,实现对电网的友好接入与稳定支撑。该模型充分考虑了光伏出力的波动性和间歇性,利用储能系统平抑功率波动,并通过VSG控制策略模拟同步发电机的惯性和阻尼特性,提升系统频率和电压调节能力。文中详细阐述了各模块的设计与实现,包括光伏阵列、储能单元、双向变流器及VSG控制算法,并在Simulink环境中完成整体建模与仿真验证,展示了系统在并网运行下的动态响应性能。; 适合人群:电气工程、自动化、新能源等相关专业的研究生、科研人员及从事电力系统仿真与控制的技术人员。; 使用场景及目标:①用于研究高比例可再生能源接入背景下电力系统的稳定性问题;②为虚拟同步机控制策略的设计与优化提供仿真平台;③支持微电网、智能电网中的源网协调控制技术开发与教学实验。; 阅读建议:建议读者结合Simulink软件动手搭建模型,深入理解各模块参数设置与控制逻辑,重点关注VSG的有功-频率、无功-电压调控机制,并可通过改变光照强度、负载扰动等条件进行仿真实验,分析系统动态特性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值