#E. 环上子段和

    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.

题面背景

环上子段和

题目描述

给你一个序列 aa ,现在需要你求出它的最大子段和。

需要注意,这是一个首尾相接的环形序列,序列中的数不一定全是正数。

输入格式

第一行一个整数 nn

第二行 nn 个整数表示 aia_i

输出格式

输出一个整数, 表示最大子段和

样例 #1

样例输入 #1

5
1 2 -3 -4 3

样例输出 #1

6

数据范围

  • 对于 50%50\% 的数据,1n5×1031\le n\le 5 \times 10^3
  • 对于 100%100\% 的数据,1n106,106ai1061\le n\le 10^6, -10^6 \le a_i \le 10^6

2025北辰贺岁杯基础赛-(复现赛)

Not Attended
Status
Done
Rule
Ledo
Problem
6
Start at
2025-1-20 9:00
End at
2025-2-22 17:00
Duration
800 hour(s)
Host
Partic.
49