問題一覧 > 通常問題

No.99 Jumping Pieces

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 565
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 191 / 自分の提出
問題文最終更新日: 2026-06-28 05:16:49
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 63 (順位表) の他の問題:

Problem Statement

There are $N$ pieces at integer coordinates on a one-dimensional number line.
The initial coordinates of the pieces are pairwise distinct and are $X_1,X_2,\ldots,X_N$.
In $1$ operation, you can move $1$ piece: if its current coordinate is $x$, it can move to $x+2$ or $x-2$.
However, such a move is not allowed if there is already a piece at the destination. Also, if a piece jumps over another piece while moving, both the jumping piece and the piece jumped over disappear.
You want to minimize the number of pieces.
Write a program that finds the minimum possible number of pieces remaining at the end, given that you may perform any number of operations.

Input

$N$
$X_1$ $X_2$ $\cdots$ $X_N$

$1 \leq N \leq 10^5$
$-10^9 \leq X_k \leq 10^9$

Output

Output the minimum number of remaining pieces on $1$ line.
Print a newline at the end.

Sample

Sample 1
Input
4
1 2 4 3
Output
0

If the piece at coordinate $2$ jumps over the piece at coordinate $1$, and then the piece at coordinate $4$ jumps over the piece at coordinate $3$, all the pieces disappear.

Sample 2
Input
10
-746 0 11 98 1 14 998 123 837 15
Output
0

Apparently, if you do things well somehow, all of them disappear.

Sample 3
Input
5
1000000000 -1000000000 0 987654321 -123456789
Output
1

Since pieces disappear in sets of $2$, $1$ piece inevitably remains at the end.
Also, it is possible to make $4$ pieces disappear.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。