Redian新闻
>
“封神榜”的编剧吃了屎了
avatar
“封神榜”的编剧吃了屎了# TVChinese - 中文电视
c*e
1
Suppose you have an array of integers a[0],...,a[n]. Design an algorithm
to find the maximum sum of any contiguous subarray. Optimize speed.
avatar
T*i
2
这杨戬智商太低了 好歹是二郎显圣 被人耍的团团转
这编剧也太下三滥了 相似的桥段用了再用 马的有这样骗稿费的嘛?
avatar
l*r
3
for i=1 to n
maxendinghere=max(maxendinghere+x_i,0)
maxsofar=max(maxsofar,maxendinghere)

【在 c**********e 的大作中提到】
: Suppose you have an array of integers a[0],...,a[n]. Design an algorithm
: to find the maximum sum of any contiguous subarray. Optimize speed.

avatar
c*e
4
The following code is from a book. But it does not work.
I have not been able to make it work. Anybody look at it?
________________________________
#include
#include
using namespace std;
int maxSub(int a[], int n, int& i, int& j) {
int t=a[0], vmax = a[0];
int tmin = min(0, t);
for(int k=1; k{
t+=a[k];
if(t-tmin > vmax) { vmax = t-tmin; j=k; }
if(t < tmin) { tmin =t; i=(k+1}
return vmax;
}
int main() {
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。