Type: RemoteJudge 1000ms 125MiB

最大子段和

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给出一个长度为 nn 的序列 aa,选出其中连续且非空的一段使得这段和最大。

输入格式

第一行是一个整数,表示序列的长度 nn

第二行有 nn 个整数,第 ii 个整数表示序列的第 ii 个数字 aia_i

输出格式

输出一行一个整数表示答案。

7
2 -4 3 -1 2 -4 3

4

提示

样例 1 解释

选取 [3,5][3, 5] 子段 {3,1,2}\{3, -1, 2\},其和为 44

数据规模与约定

  • 对于 40%40\% 的数据,保证 n2×103n \leq 2 \times 10^3
  • 对于 100%100\% 的数据,保证 1n2×1051 \leq n \leq 2 \times 10^5104ai104-10^4 \leq a_i \leq 10^4

天河C23开学摸底测试

Not Attended
Status
Done
Rule
IOI
Problem
9
Start at
2023-9-12 18:30
End at
2023-9-12 19:54
Duration
1.4 hour(s)
Host
Partic.
4