如何找到最高平均水平(USACO) [英] How to find Maximum average(USACO)

查看:90
本文介绍了如何找到最高平均水平(USACO)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个数组a1,a2,a3 ...和一个部分(至少L的长度)..如何找到最大平均值

give a array a1,a2,a3... and a section (Length of at least L).. how to find Maximum average

推荐答案

不知道有什么漂亮的算法,但是为什么不只计算每个部分的平均值,而使用最大的呢?毕竟这只是一个简单的嵌套循环...

我打算发布一种更加整洁的解决方案,该解决方案不需要一个循环,只需很少的指令,但是随后我检查了USACO [ ^ ]是:您是否要利用我们为您赢得比赛?因为如果有的话,就是这样:作弊.
I don''t know any pretty algorithms for this, but why not just calculate the average for each section, and use the largest? It''s only a simple nested loop, after all...

I was going to post a much neater solution, that doesn''t need more than one loop with very few instruction in that, but then I checked what USACO[^] is: Are you trying to use us to win a competition for you? Because if you are, there is a word for that: Cheating.


这篇关于如何找到最高平均水平(USACO)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆