Problem list
Log in
#usaco0696 · USACO 2025-2026 Second Contest Platinum

Circle of Cows

Platinum III 2.0 s 256 MB

Farmer John has $N$ ($2\le N\le 1000$) cows at distinct locations $l_1,\dots, l_N$ along a circle of circumference $C$ ($0\le l_1 < l_2 < \dots < l_N <C, N\le C\le 10^9$).

FJ will select $k$ pairs of cows, where $1\le k\le \lfloor N/2\rfloor$, and no cow is selected more than once. He wants to select the pairs such that the minimum distance between any two cows in the same pair along the circumference of the circle is maximized.

For each value of $k$, help FJ determine the maximum possible minimum distance.

Input

The first line contains $N$ and $C$.

The second line contains $l_1\dots l_N$.

Output

Output a single line with $\lfloor N/2\rfloor$ space-separated integers, with the answers for $k=1\dots \lfloor N/2\rfloor$ in that order.

Constraints

SCORING

  • Inputs 3-4: $2l_N \le C$
  • Inputs 5-6: $N\le 20$
  • Inputs 7-14: $N\le 100$
  • Inputs 15-22: No additional constraints.

Example 1

Input
4 100
0 25 50 75
Output
50 50

For $k = 1$, cow 1 can be paired to cow 3, which is distance $50$ away along the circumference of the circle, making the answer $50$.

For $k = 2$, cow 1 can be paired to cow 3, and cow 2 can be paired to cow 4, which is distance $50$ away from it along the circumference of the circle, making the answer still $50$.

Example 2

Input
4 100
0 1 2 99
Output
3 2

For $k = 1$, cow 3 can be paired to cow 4, which is distance $2 + 100 - 99 = 3$ away from it along the circumference of the circle, making the answer $3$.

For $k = 2$, cow 1 can be paired to cow 3 and cow 2 can be paired to cow 4. Each of these pairs contains two cows at a distance of $2$ from each other along the circumference of the circle, making the answer $2$.

Problem credits: Benjamin Qi

Source
USACO 2025-2026 Second Contest Platinum
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code