J. 最大子序列和

    Type: Default 1000ms 256MiB

最大子序列和

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.

题目背景

翻译自 CSES-1643 题。

题目描述

给定一个由 nn 个整数组成的数组,你的任务是找出一个连续的非空子序列中数值的最大和。

输入格式

第一行输入整数 nn,代表数组的大小。

第二行有 nn 个整数 x1,x2,,xnx_1,x_2,\dots,x_n,分别代表数组值。

输出格式

输出一个整数,表示最大子序列和。

样例

8
-1 3 -2 5 3 -5 2 2
9

说明/提示

1n2105,109xi1091 \leq n \leq 2\cdot 10^5,-10^9 \le x_i \le 10^9

CSES练习二 排序贪心STL

Not Claimed
Status
Done
Problem
35
Open Since
2025-5-1 0:00
Deadline
2025-5-31 23:59
Extension
24 hour(s)