← CSES Better

Mana Collection

USACO · 2023 · January · platinum-2

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

dynamic-programming · graph-algorithms · sorting

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

sample trace

Mana Collection: dynamic programming walkthrough

Mana Collection: use the linked editorial?s dynamic programming, graph algorithms idea on the published sample, then verify the displayed output.

Published input2 1 1 10 1 2 10 4 5 1 5 2 100 1 100 2 4 8 50000000 100000000 20000000 70000000 1 2 20 2 1 50 2 3 90 1 3 40 3 1 10 4 1 25 1 4 5 4 3 70 3 8 3 1000000000 1 500000 4modelAlgorithm ideaTrack smaller states that summarize partial solutions. For each state, combine the legal predecessor states; the full-task state gives the result.task resultExpected output5 50 100 1090 160000000 239999988050000000 119992550000000
  1. 1

    State

    Choose a compact value for each partial subproblem so later choices need only that summary.
  2. 2

    Transition

    Combine legal smaller states to compute reachability, a count, or an optimum for the next state.
  3. 3

    Finish

    Read the state representing the full task and compare it with the published sample output.
  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.