UNICORN 编程竞赛 2026(第 477 场 AtCoder Beginner Contest)
B
突出的离群者
Standing Outliers
AtCoder
⌀ 0
原题
← AC →

突出的离群者AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

There are $N$ people on a number line. The people are numbered $1$ to $N$, and person $i$ is at coordinate $X_i$. Multiple people may be at the same coordinate.

数轴上有 $N$ 个人。人们的编号为 $1$ 到 $N$,第 $i$ 个人位于坐标 $X_i$。多个 人可能位于同一坐标。AI (CI翻译)

A person is said to "stand apart" if their distance to every other person is at least $D$.

如果一个人与其他每个人的距离都至少为 $D$,则称这个人“独立突出”。AI (CI翻译)

Formally, person $i$ is said to "stand apart" if $|X_i-X_j| \geq D$ holds for all $j ~ (1 \leq j \leq N,\ j \neq i)$.

形式化地说,对于所有满足 $j ~ (1 \leq j \leq N,\ j \neq i)$ 的 $j$,若均有 $|X_i-X_j| \geq D$,则称第 $i$ 个人“独立突出”。AI (CI翻译)

Output the numbers of all people who "stand apart" in ascending order.

请按升序输出所有“独立突出”的人的编号。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $2 \le N \le 100$
  • $1 \le D \le 10^9$
  • $1 \le X_i \le 10^9$
  • All input values are integers.
  • $2 \leq N \leq 100$
  • $1 \leq D \leq 10^9$
  • $1 \leq X_i \leq 10^9$
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

N D
X_1 X_2 \dots X_N

N D
X_1 X_2 \dots X_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Let $K$ be the number of people who stand apart, and let $(P_1,P_2,\dots,P_K)$ be the sequence of their numbers sorted in ascending order. Output them in the following format:

设独立突出的人数为 $K$,将这些人的编号按升序排列后得到序列 $(P_1,P_2,\dots,P_K)$。请按以下格式输出:AI (CI翻译)

K
P_1 P_2 \dots P_K

K
P_1 P_2 \dots P_K
AI (CI翻译)

If $K=0$, the second line should be empty.

当 $K=0$ 时,第二行应为空。AI (CI翻译)

样例

Input #1
3 3
1 5 7
Output #1
1
1
Person $1$ has distance $4$ to person $2$ and distance $6$ to person $3$, so their distance to every other person is at least $D$. Thus, person $1$ "stands apart". Person $2$ has distance $2$ to person $3$, so person $2$ does not "stand apart". Similarly, person $3$ has distance $2$ to person $2$, so person $3$ does not "stand apart" either. Thus, only person $1$ "stands apart".
Input #2
3 2
1 1 1
Output #2
0
There may be people at the same coordinate. Also, if no one "stands apart", the second line should be empty.
Input #3
8 3
4 77 20 26 9 26 22 40
Output #3
4
1 2 5 8
Output the numbers of the people who "stand apart" in ascending order.
题目信息
题号
abc477_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。