← CSES Better

Lazy Cow

USACO · 2024 · February · platinum-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 · prefix-sums · sorting

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

sample trace

Lazy Cow: greedy walkthrough

Lazy Cow: use the linked editorial?s greedy, prefix sums idea on the published sample, then verify the displayed output.

Published input4 5 11 6 10 10 15 10 30 2 100 5 100 1000000000000 20 303590 482848034083 180190 112716918480 312298 258438719980 671877 605558355401 662137 440411075067 257593 261569032231 766172 268433874550 8114 905639446594 209577 11155741818 227183 874665904430 896141 55422874585 728247 456681845046 193800 632739601224 443005 623200306681 330325 955479269245 377303 177279745225 880246 22559233849 58084 155169139314 813702 758370488574 929760 785245728062modelAlgorithm ideaProcess choices in the order justified by the editorial and maintain the invariant that each accepted choice remains safe.task resultExpected output21 21 25 90 5 627323485 108753959 108753959 108753959 148189797 148189797 148189797 148189797 32884410 32884410 32884410 32884410 32884410 32884410 32884410 3883759 3883759 3883759 3883759 3883759 3883759
  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.