← CSES Better

Interesting Sequences

INOI · 2019 · Indian National Olympiad in Informatics · INOI1902

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

arrays · nonincreasing-values · index-distance · optimization

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

index sequence distance

Maximize the minimum adjacent index gap

Choose L indices in any order, allowing an index to repeat, so their A-values are nonincreasing. The cost is the minimum absolute gap between adjacent indices.

State table
Position in sequenceIndexRequired value relation
1i1A[i1]
2i2A[i1] >= A[i2]
.........
LiLcost = min adjacent |ij-i(j+1)|
  1. 1

    Choose an index sequence

    A sequence has length L; indices may repeat and have no required ordering.
  2. 2

    Enforce value order

    The selected values must satisfy A[i1] >= A[i2] >= ... >= A[iL].
  3. 3

    Maximize its cost

    For each valid sequence, take the minimum |ij - i(j+1)|; maximize that minimum over all sequences.
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.