发现在一个数组元素的最大总和,使得不超过k个元素是相邻 [英] find maximum sum of elements in an array such that not more than k elements are adjacent

查看:147
本文介绍了发现在一个数组元素的最大总和,使得不超过k个元素是相邻的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个自复制的拆除的广告牌给那些的,我读了这个问题的答案(及其他)仔细,但我仍然无法换我的头周围?什么soulcheck意味着他的<一个href="http://stackoverflow.com/questions/9376976/removal-of-billboards-from-given-ones/9377318#9377318">answer ?

This is a duplicated of removal of billboards from given ones, I have read the answers to this question (and others) carefully, but i still cant wrap me head around it ? what is soulcheck mean in his answer ?

我不想code,我只是想用简单的英语的算法解释。 如果提供了一个例子,我将大大AP preciate吧。

I dont want code, I just want the algorithm explained in plain english. and if an example is provided I'll greatly appreciate it .

推荐答案

他建议,使和P [N,K]数组,其中,P [I,J]将存储,能得到的最大可能值(利润)从广告牌1..i(必要时与其中的一些已删除),使得恰好有Ĵ连续的广告牌的右侧。

He suggests to make and P[n,k] array, where P[i,j] would store the maximum possible value (profit) that could be obtained from the billboards 1..i (with some of them removed if necessary), so that there are exactly j consecutive billboards at the right side.

编辑: 顺便说此解决方案不符合该问题的要求(N其中; = 10 ^ 5)

By the way this solution doesn't meet the requirements of the problem (N <= 10^5)

这篇关于发现在一个数组元素的最大总和,使得不超过k个元素是相邻的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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