当前位置: 首页 > news >正文

哪里做网站做的好西地那非片的功能主治

哪里做网站做的好,西地那非片的功能主治,阿里云添加网站,威海住房建设部官方网站通过万岁#xff01;#xff01;#xff01; 题目#xff1a;就是一个摩天轮#xff0c;一共有4个仓位#xff0c;一个仓位中最多可以做4个人。然后每次上一个人boardingCost钱#xff0c;但是我们转动1/4圈#xff0c;需要的成本是runningCost。然后给我们一个数组cu…通过万岁 题目就是一个摩天轮一共有4个仓位一个仓位中最多可以做4个人。然后每次上一个人boardingCost钱但是我们转动1/4圈需要的成本是runningCost。然后给我们一个数组customers数组中是人数而下标i表示我们转动多少次也就是说我们转动i次的时候会来customers[i]个人。如果坐满了那么多余的人只能等待下一批也就是i1的时候而且这是时候也会来customers[i1]个人。但是题目中有个地方有点迷惑人假设我们在某个位置决定停止营业则需要将上面所有的人都送下来才行。问我们第几次转动的盈利是最大的。基础思路首先看一下我说的迷惑人的地方可以发现其实我们不用考虑把人送下来因为我们如果停止营业把人送下来那么送下来的过程一定是亏本的。那么盈利最大值的肯定在此之前。然后再说一下我们的思路就是模拟这个过程就好了。首先我们需要遍历数组并且需要记录一下剩余的人数如果两者之和大于4则按照上4人的盈利标准来。否则按照现有的人数来计算。然后跟max的利润进行比较就好了。当我们遍历完数组之后我们还需要遍历剩余的人数将这些人安排好。在此过程中我们就可以找到最大值了。优化思路其实在遍历完数组以后针对剩余人数的计算可以进行优化的。如果上4人可以盈利的话那么我们将剩余人数/4*每次的盈利然后在针对不足4人的情况继续考虑。技巧模拟 java代码——基础 class Solution {public int minOperationsMaxProfit(int[] customers, int boardingCost, int runningCost) {int maxcurrProfit Integer.MIN_VALUE;int currProfit 0;int maxIdx 0;int surplusCustomer 0;int i 0;for (; i customers.length; i) {if (surplusCustomer customers[i] 4) {currProfit boardingCost * 4 - runningCost;surplusCustomer surplusCustomer customers[i] - 4;} else {currProfit boardingCost * (surplusCustomer customers[i]) - runningCost;surplusCustomer 0;}if (maxcurrProfit currProfit) {maxcurrProfit currProfit;maxIdx i;}}while (surplusCustomer 0) {if (surplusCustomer 4) {currProfit boardingCost * 4 - runningCost;surplusCustomer surplusCustomer - 4;} else {currProfit boardingCost * surplusCustomer - runningCost;surplusCustomer 0;}if (maxcurrProfit currProfit) {maxcurrProfit currProfit;maxIdx i;}i;}return maxcurrProfit 0 ? -1 : maxIdx 1;} }java代码——优化 class Solution {public int minOperationsMaxProfit(int[] customers, int boardingCost, int runningCost) {int maxProfit Integer.MIN_VALUE;int currProfit 0;int maxIdx 0;int surplusCustomer 0;int i 0;for (; i customers.length; i) {if (surplusCustomer customers[i] 4) {currProfit boardingCost * 4 - runningCost;surplusCustomer surplusCustomer customers[i] - 4;} else {currProfit boardingCost * (surplusCustomer customers[i]) - runningCost;surplusCustomer 0;}if (maxProfit currProfit) {maxProfit currProfit;maxIdx i;}}// 因为i已经是越界的了所以这里要减1i--;// 都上会盈利if (boardingCost * 4 - runningCost 0) {return maxProfit 0 ? -1 : maxIdx 1;}currProfit (boardingCost * 4 - runningCost) * (surplusCustomer / 4);if (maxProfit currProfit) {maxProfit currProfit;i surplusCustomer / 4;maxIdx i;}currProfit (boardingCost * (surplusCustomer % 4) - runningCost);if (maxProfit currProfit) {maxProfit currProfit;i;maxIdx i;}return maxProfit 0 ? -1 : maxIdx 1;} }总结题目不是特别难我最开始主要是被我说的迷惑的地方绕进去了。
http://www.zqtcl.cn/news/545641/

相关文章:

  • 网站icp备案费用浅谈做网站的好处
  • 制作网站需要懂哪些在线设计平台的市场调研
  • 接计设做的网站河南网站建设华企祥云
  • 网站系统维护一般要多久企业网站推广工具
  • 如何诊断网站seo做个网站商场需要多少
  • 腾讯云做视频网站吗创业商机网加工项目
  • 网站建设论文文献郑州seo外包费用
  • 网站优化西安如何免费推广网站
  • 固原市建设局网站外贸网站建设方法
  • 做违规网站主页制作语言缩写
  • 汝南县网站建设怎么注册公司钉钉账号
  • 网站建设酷隆信通网站开发中心
  • 保定网站建设方案报价怎么做网站_
  • 做网站功能的框架结构图做网站用python好吗
  • 襄樊市网站建设模版网站建设企业
  • 网站换服务器php大流量网站开发规范
  • 网站备案主体域名平面设计线下培训班多少钱
  • 优秀网站专题wordpress 外部调用插件
  • 域名服务网站建设科技公司做棋子网站怎么提高浏览量
  • 用易语言做攻击网站软件下载彩页设计多少钱
  • 个人网站可以做淘宝推广手机版怎么用百度快照
  • 制作网站的公司叫什么外包软件
  • 廊坊企业建站模板邱县手机网站建设
  • 辽宁响应式网站费用建设银行官网app
  • 河北黄骅市网站建设网站外链的优化方法
  • 青岛城阳网站制作网站建设详细步骤
  • 先做网站再付款 怎么回答设计方案步骤
  • 汕头建站模板济南网站建设富库网络
  • 创业网站建设方案项目书手机app设计软件
  • 建设端午节网站的目的主题wordpress语法高亮插件