← CSES Better

Valleys

USACO · 2019 · US Open · platinum-3

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

data-structures

The organizer’s problem statement is available at the official source link.

sample trace

Valleys: data structures walkthrough

Valleys: use the linked editorial?s data structures idea on the published sample, then verify the displayed output.

Published input3 1 10 2 20 100 30 3 11 50modelAlgorithm ideaMaintain the changing values in a structure that supports the editorial?s updates and queries efficiently.task resultExpected output30
  1. 1

    Build

    Store the task?s elements or ranges in the required query structure.
  2. 2

    Update

    Apply each change to the affected part of the structure.
  3. 3

    Query

    Read the requested aggregate or candidate from the maintained state.
  4. 4

    Verify the sample

    Use the published sample output to check the result of this idea on the displayed input.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.