Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopsorting · 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.
| Shelf A | Shelf B | Skew |
|---|---|---|
| max A | max B | max A + max B |
- 1
Locate controlling books
Sort book heights and identify which large books control each shelf maximum. - 2
Evaluate exchanges
Evaluate exchanges that move those controlling books while preserving shelf sizes. - 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 charsRun output
Run your code to see output.