← CSES Better

Bookshelves

ZCO · 2016 · Zonal Computing Olympiad · ZCO16001

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 · optimization · exchange

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

two shelves

Only the largest books determine the skew

After up to K exchanges, minimize the sum of the two shelf maximum heights while keeping N books on each shelf.

State table
Shelf AShelf BSkew
max Amax Bmax A + max B
  1. 1

    Locate controlling books

    Sort book heights and identify which large books control each shelf maximum.
  2. 2

    Evaluate exchanges

    Evaluate exchanges that move those controlling books while preserving shelf sizes.
  3. 3

    Minimize shelf maxima

    Choose the reachable exchange plan with the smallest combined maxima.
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.