← CSES Better

Paired Up

USACO · 2021 · December · 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

sorting

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

sample trace

Paired Up: sorting walkthrough

Paired Up: use the linked editorial?s sorting idea on the published sample, then verify the displayed output.

Published input2 5 4 G 1 1 H 3 4 G 4 2 H 6 6 H 8 9 1 5 4 G 1 1 H 3 4 G 4 2 H 6 6 H 8 9 2 10 76 H 1 18 H 18 465 H 25 278 H 30 291 H 36 202 G 45 96 G 60 375 G 93 941 G 96 870 G 98 540modelAlgorithm ideaSort by the task-relevant key so the ordering exposes candidates that can be checked locally.task resultExpected output16 6 1893
  1. 1

    Order

    Sort items by the comparison key used by the task.
  2. 2

    Scan

    Inspect the ordered neighbors or groups and update the candidate result.
  3. 3

    Finish

    Use the final aggregate or selected item as the answer.
  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.