Skip to main content

Practice · 1 of 6

Contest 1 — Problem A: The Wall

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** A wall is divided into n segments; repainting segment i gains a[i] value (which may be negative). You must repaint a non-empty set of consecutive segments. Print the maximum possible total value. **Constraints:** 1 ≤ n ≤ 200000; −4986 ≤ a[i] ≤ 4986. **Input:** line 1: n; line 2: n values. **Output:** one integer — the maximum consecutive sum over non-empty windows.

Back to lesson: Practice: Mock Contests 1 & 2