Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktoparrays · optimization · dynamic-programming
The organizer’s problem statement is available at the official source link.
sequence
Choose a consecutive target band
A beautiful sequence has one shared starting height; each next target rises by one.
| Index | Original height | Target height |
|---|---|---|
| i | H_i | x+i |
| all i | H_i >= 1 | min sum |H_i-(x+i)| |
- 1
Pick a start
For a target beginning at x, position i must become x + i. - 2
Compare costs
For each position, count additions or legal removals needed to reach its target; heights cannot fall below one. - 3
Take the least
The answer is the minimum total adjustment cost over valid starting heights.
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.