Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
This post was edited and submitted for review 6 months ago and failed to reopen the post:
Needs more focus Update the question so it focuses on one problem only by editing this post.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
n+1
是因为前缀总和还需要包括一个空子阵列。int_min
最大值,因为max()
函数将两个值中的较大的函数占据,因此maxsum
始终增加。如果您在开始或其他数字时制作maxsum = 0
,则有可能0
大于任何实际总和。为了确保默认值不会覆盖实际值,您将其设置为尽可能低。N+1
is used because prefix sums also needs to include an empty subarray.INT_MIN
for maximum because themax()
function takes the larger of the two values, soMaxSum
is always increasing. If you makeMaxSum = 0
at the beginning, or some other number, there is a chance that0
is larger than any of the actual sums. To make sure that the default value does not override the actual values, you set it to as low as possible.