Logo
(追記) (追記ここまで)

30543번 - Bombardment 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 (추가 시간 없음) 1024 MB111111100.000%

문제

You are designing an old-school game you call Bombardment where the goal is to destroy a number of points by bombarding them. You do not yet know the theme of your game, just that the core mechanics should involve a bombardment.

The points to be destroyed are located on the real number line, that is each point is simply an $x$-coordinate. A bombardment is an attack that will destroy all points within some fixed distance $R$ from the center of the bombardment. More specifically, a single bombardment is specified by picking an integer point $X$ (the center). All points lying in the interval $[X-R, X+R]$ will be destroyed.

You decide to playtest a basic version of this game before you go through the effort of designing a theme, adding nice graphics, etc. Interestingly, most testers seemed to employ a greedy strategy: each bombardment is chosen to destroy the maximum number of points in that single bombardment. Sometimes, this causes players to use more bombardments than the minimum possible number of bombardments. You want to design a program that will simulate this strategy, this will help you design interesting levels.

That is, your job is to write a program that will simulate the following process. While there are still points remaining, choose a value $X$ for a bombardment that will destroy the maximum number of remaining points. If there are multiple values $X$ for the center of such a bombardment, you will choose the least such $X$ each time.

입력

The first line of input contains two integers $N$ (1ドル \leq N \leq 5 \times 10^5)$ and $R$ (1ドル \leq R \leq 10^8$). The next line contains $N$ integers describing the $x$-coordinates of the points, each lying in the range $[-10^8, 10^8]$. Multiple points may share the same $x$-coordinate. You are also guaranteed that the difference between the maximum $x$-coordinate and the minimum $x$-coordinate is at most 40ドル \cdot R$.

출력

The first line of output contains a single integer $B$ indicating the number of bombardments that were performed. The second line consists of $B$ integers describing the $x$-coordinates of each bombardment in the order they were performed.

제한

예제 입력 1

7 1
1 2 3 3 4 4 5

예제 출력 1

3
3 0 4

예제 입력 2

6 1
5 -2 5 0 1 2

예제 출력 2

3
1 4 -3

예제 입력 3

6 2
5 -2 5 0 1 2

예제 출력 3

2
0 3

예제 입력 4

6 3
5 -2 5 0 1 2

예제 출력 4

2
2 -5

힌트

출처

ICPC > Regionals > North America > North Central North America Regional > 2023 North Central NA Regional Contest D번

ICPC > Regionals > North America > Rocky Mountain Regional > 2023 Rocky Mountain Regional Contest G번

  • 문제를 만든 사람: Zachary Friggstad
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /