Type: Default 1000ms 256MiB

最大子段和1

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

数据规模与约定

  • 对于 100%100\% 的数据,保证 n2×102n \leq 2 \times 10^2

季科_周六早上

Not Claimed
Status
Done
Problem
13
Open Since
2025-3-21 0:00
Deadline
2026-2-19 23:59
Extension
24 hour(s)