← CSES Better

Cowmpetency

USACO · 2024 · January · silver-1

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

greedy

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

sample trace

Cowmpetency: greedy walkthrough

Cowmpetency: use the linked editorial?s greedy idea on the published sample, then verify the displayed output.

Published input1 7 3 5 1 0 2 3 0 4 0 1 2 3 4 4 5 5 7 6 10 0 0 0 0 0 0 0 1 2 2 3 3 4 4 5 5 6 6 7 8 4 9 0 0 0 0 1 6 0 6 1 3 6 7 4 7 2 3 2 1 1 0 0 1 2 10 4 10 1 2 0 2 1 5 8 6 0 3 4 7 1 2 5 7 3 7 10 2 8 1 0 0 0 0 5 7 0 0 0 4 6 6 9modelAlgorithm ideaProcess choices in the order justified by the editorial and maintain the invariant that each accepted choice remains safe.task resultExpected output1 2 2 3 4 4 1 1 2 3 4 5 6 7 1 1 2 6 1 6 7 6 -1 1 2 5 2 1 5 8 6 1 3 -1
  1. 1

    Order

    Arrange candidates by the criterion used by the task?s greedy strategy.
  2. 2

    Choose

    Accept the next locally safe option while preserving the feasibility invariant.
  3. 3

    Finish

    Read the accumulated result and check it against the 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.