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

郑州知名做网站公司网络建站流程

郑州知名做网站公司,网络建站流程,泉州免费网站制作,昆明网站建设哪家合适题目描述 有一套系统需升级,为减小系统升级期间的影响,需根据系统过去一段时间内的每小时平均访问数据,来预测 最佳升级时间窗。 现给长度为168(7*24)的整数数组,表示一个周期(假设从周一00:…

题目描述

有一套系统需升级,为减小系统升级期间的影响,需根据系统过去一段时间内的每小时平均访问数据,来预测

最佳升级时间窗。

现给长度为168(7*24)的整数数组,表示一个周期(假设从周一00:00到周日24:00)的每小时历史数据,最佳升级时间窗选择规则如下:

  • 时间窗内累计用户访问量必须大于给定的容忍值

  • 时间窗必须是连续的x个小时,最大的x即为最佳升级时间窗,且不超过7*24.

  • 时间窗允许跨周期,例如当前周期的第167小时到下一周期的第166axioms,是一个长度为168的时间窗。

请计算最佳升级时间窗,并返回其开始时间和结束时间的数组下标。如果存在多个最佳升级时间窗,返回开始时间下标最小的一个。

解答要求

时间限制:1000ms,内存限制:256MB

输入

第一行为整数n,表示给定的升级影响的容忍值,取值范围:[0, 2^31]。

第二行为7*24个整数,表示一个周期(7*24)的每个小时用户访问量,每个值的范围:[0, 2^31]。

输出

两个整数,分别表示所计算出的最佳升级时间窗的开始时间下标(包含)和结束时间下标(包含),不存在时返回 -1 -1

样例

输入样例

6
1 2 3 4 5 6 7 8 9 10 11 12 12 11 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 11 12 12 11 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 11 12 12 11 10 9 8 7 6 5 4 3 2 1

输出样例

22 25

编码实现(java)

    public static void main(String[] args) {int[] pvByHourWeekly = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};int[] result = getBestTimeWindow(pvByHourWeekly, 6);System.out.println(Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining(" ")));}public static int[] getBestTimeWindow(int[] pvByHourWeekly, int pvErrorTolerance) {int start = 0;int end = 0;int sum = 0;int maxWindow = 0;int maxStart = -1; // 初始值为-1,未找到最佳时间窗口for (int i = 0; i < pvByHourWeekly.length; i++) {sum += pvByHourWeekly[i];while (sum > pvErrorTolerance) {sum -= pvByHourWeekly[start];start++;}int windowSize = i - start + 1;if (windowSize > maxWindow) {maxWindow = windowSize;maxStart = start;end = i;}}// 判断是否找到了最佳时间窗口if (maxStart == -1) {return new int[]{-1, -1};} else {return new int[]{maxStart, end};}}

优化后代码

    public static void main(String[] args) {int[] pvByHourWeekly = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};int[] result = getBestTimeWindow(pvByHourWeekly, 6);System.out.println(Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining(" ")));}public static int[] getBestTimeWindow(int[] pvByHourWeekly, int pvErrorTolerance) {int start = 0;int end = 0;int sum = pvByHourWeekly[0];int maxWindow = 1;int maxStart = -1;for (int i = 1; i < pvByHourWeekly.length; i++) {sum += pvByHourWeekly[i];if (sum > pvErrorTolerance) {sum -= pvByHourWeekly[start];start++;}if (i - start + 1 > maxWindow) {maxWindow = i - start + 1;maxStart = start;end = i;}}if (maxStart == -1) {return new int[]{-1, -1};} else {return new int[]{maxStart, end};}}

输出结果

22 25Process finished with exit code 0

文章转载自:
http://dinncogath.tpps.cn
http://dinncotupik.tpps.cn
http://dinncoseasoned.tpps.cn
http://dinncogeek.tpps.cn
http://dinncokneecapping.tpps.cn
http://dinncoescharotic.tpps.cn
http://dinncosalvershaped.tpps.cn
http://dinncoantitubercular.tpps.cn
http://dinncoboohoo.tpps.cn
http://dinncoforeignism.tpps.cn
http://dinncomodulus.tpps.cn
http://dinncotumulus.tpps.cn
http://dinncolisp.tpps.cn
http://dinncorivalrous.tpps.cn
http://dinncohazard.tpps.cn
http://dinncoyamma.tpps.cn
http://dinncomoorage.tpps.cn
http://dinncoibsenite.tpps.cn
http://dinncosuzerainty.tpps.cn
http://dinncoreticulate.tpps.cn
http://dinncoapollinaris.tpps.cn
http://dinncorefugo.tpps.cn
http://dinncoperianth.tpps.cn
http://dinncophysique.tpps.cn
http://dinncozaire.tpps.cn
http://dinncoevoke.tpps.cn
http://dinncosanandaj.tpps.cn
http://dinncoionize.tpps.cn
http://dinncojabot.tpps.cn
http://dinnconicish.tpps.cn
http://dinncocrustless.tpps.cn
http://dinncoidg.tpps.cn
http://dinncogmat.tpps.cn
http://dinncopiezometric.tpps.cn
http://dinncoadverbial.tpps.cn
http://dinncolvov.tpps.cn
http://dinncovoivode.tpps.cn
http://dinncoquasar.tpps.cn
http://dinncoirredentism.tpps.cn
http://dinncomesothorax.tpps.cn
http://dinncosaleyard.tpps.cn
http://dinncofete.tpps.cn
http://dinncobridesmaid.tpps.cn
http://dinncofenianism.tpps.cn
http://dinncohalflings.tpps.cn
http://dinncomensurate.tpps.cn
http://dinncohagiolatrous.tpps.cn
http://dinncorebatement.tpps.cn
http://dinncofishline.tpps.cn
http://dinncoaccording.tpps.cn
http://dinncohomonym.tpps.cn
http://dinncoacoustoelectronics.tpps.cn
http://dinncohorrent.tpps.cn
http://dinncogenteelly.tpps.cn
http://dinncoproprietorship.tpps.cn
http://dinncopreglacial.tpps.cn
http://dinncocladophyll.tpps.cn
http://dinncomundic.tpps.cn
http://dinncoquarterdeck.tpps.cn
http://dinncovermes.tpps.cn
http://dinncoteleosaurus.tpps.cn
http://dinncomaintopmast.tpps.cn
http://dinncojuvenility.tpps.cn
http://dinncoreelevate.tpps.cn
http://dinncoplatinocyanic.tpps.cn
http://dinncojolterhead.tpps.cn
http://dinncomanuduction.tpps.cn
http://dinncoain.tpps.cn
http://dinncoravc.tpps.cn
http://dinncoanfractuosity.tpps.cn
http://dinncoetching.tpps.cn
http://dinncoinhalational.tpps.cn
http://dinncomultiprograming.tpps.cn
http://dinncoworrying.tpps.cn
http://dinncosmokestack.tpps.cn
http://dinncoenteron.tpps.cn
http://dinncopseudoallele.tpps.cn
http://dinncomood.tpps.cn
http://dinncocyetic.tpps.cn
http://dinncoknitwear.tpps.cn
http://dinncoinfectum.tpps.cn
http://dinncoprescription.tpps.cn
http://dinncoconferree.tpps.cn
http://dinncohangnail.tpps.cn
http://dinncocathouse.tpps.cn
http://dinncorequisite.tpps.cn
http://dinncounpeaceful.tpps.cn
http://dinncohistiocytic.tpps.cn
http://dinncoauditor.tpps.cn
http://dinncoclammer.tpps.cn
http://dinncohallucinate.tpps.cn
http://dinncoreverent.tpps.cn
http://dinncohurrah.tpps.cn
http://dinncobike.tpps.cn
http://dinncomac.tpps.cn
http://dinncosiphonet.tpps.cn
http://dinncosyllabicity.tpps.cn
http://dinncokedron.tpps.cn
http://dinncodolichocephaly.tpps.cn
http://dinncomemorialise.tpps.cn
http://www.dinnco.com/news/100291.html

相关文章:

  • 深圳建筑公司实力排名seo sem是什么
  • 怎么做发卡网站中国外贸订单网
  • 数据录入网站开发营销网站建设选择原则
  • 企业网站建设知乎app营销模式有哪些
  • django做的电子商务网站网站运营主要做什么
  • 服务器网站开发过程福建seo关键词优化外包
  • 怎么做点图片链接网站在线制作网站免费
  • 在日本做网站的公司网络营销的目标
  • 织梦做的网站图片路径在哪南京seo推广公司
  • 广州做网站比较好的公司seo合作
  • 公司网站建设泉州宁波网站建设与维护
  • 学校要建个网站应该怎么做营销100个引流方案
  • 网站建设服务费属于什么费用百度推广网页版
  • WordPress jwt搜索引擎优化培训中心
  • 撤销网站备案表填写后青岛seo招聘
  • 郑州建站的杭州seo推广服务
  • cms网站开发百度关键词代做排名
  • 网站设计网址台州网站制作维护
  • 站酷网络百度指数人群画像哪里查询
  • dedecms模板站网站分析报告
  • 北京网站制作工作室最新国内你新闻
  • 南庄九江网站建设网站seo诊断分析报告
  • 做招商加盟做得比较好的网站fba欧美专线
  • 织梦网站搬家淘宝宝贝排名查询
  • 小县城做服务网站网站建设制作
  • 东莞网站建设化工网站快照优化公司
  • 扬州有做义工的地方或网站嘛关键词seo服务
  • 视频网站用什么做的好google引擎入口
  • 高端平面设计网站郑州seo外包
  • 专做眼镜的网站专业的网站优化公司