Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopbrackets · stack · parsing
The organizer’s problem statement is available at the official source link.
typed bracket stack
A closing token must match the most recent opener
Choose a subsequence of values whose corresponding typed brackets form a well-bracketed sequence, maximizing the sum.
open type t -> pushclose type t -> match topempty stack -> balanced
- 1
Choose or skip positions
A selected bracket position contributes its value; unselected positions disappear. - 2
Maintain valid nesting
Opening and closing bracket types must match in properly nested order. - 3
Maximize selected values
Among all well-bracketed subsequences, keep the greatest sum, including negative values correctly.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.