Astronomer

면접 대비

시간 제한5초메모리 제한1024 MB

요약
별 k개 이상을 덮는 원의 중심과 반지름 r을 정해, 원점에서 중심까지의 거리에 s를, r에 t를 곱한 값의 합을 최소화한다.
난이도

어려움10점 중 8점

유형
기하, 이분 탐색, 완전 탐색, 구현
정답자
아직 제출이 없습니다

문제

The astronomer has a passion for stargazing. In particular, he gets immense pleasure out of gazing at kk stars simultaneously through his telescope. Building a telescope with radius rr costs t⋅rt\cdot r kroner. A newly built telescope will point exactly at the origin (0,0)(0,0). Moving it to point somewhere else also takes effort; shifting the telescope a distance of dd units incurs a cost of s⋅ds\cdot d kroner. The astronomer can observe all stars at distance at most rr from where the telescope points.

How much does it cost to build and move a telescope that allows kk stars to be observed at once?

All coordinates and distances are given in the Euclidean plane.

Here is an example with n=3n=3 stars at positions (0,0)(0,0), (2,0)(2,0), and (3,1)(3,1). The shaded area shows a telescope of radius 11 pointing at (1,0)(1,0) covering two stars; this costs s+ts + t kroner and is an optimal solution to sample input 33. The image also shows optimal solutions to sample inputs 11, 22, and 44.

입력

The first line consists of four integers: the number kk of stars the astronomer wants to observe, the number nn of stars in tonight's sky, the shifting cost ss, and the telescope building cost tt. Then follow nn lines, where the iith line contains the integer coordinates x_ix\_i and y_iy\_i of the iith star.

출력

A single real number: the minimum number of kroner that the astronomer needs to spend.

제한

  • 1≤k≤n≤7001\leq k\leq n\leq 700.
  • x_i,y_i∈−109,…,109x\_i, y\_i\in \\{-10^9,\ldots, 10^9\\} for all i∈1,…,ni\in\\{1,\ldots,n\\}.
  • s,t∈0,…,109s,t\in \\{0,\ldots, 10^9\\}.
  • Your output is accepted if it is within a relative or absolute tolerance of ϵ=10−6\epsilon = 10^{-6} of the correct answer.

예제5

  1. 예제 1

    입력
    2 3 1000 500
    0 0
    2 0
    3 1
    
    예상 출력
    1000.0
    
  2. 예제 2

    입력
    2 3 500 3000
    0 0
    2 0
    3 1
    
    예상 출력
    3387.277541898787
    
  3. 예제 3

    입력
    2 3 250 750
    0 0
    2 0
    3 1
    
    예상 출력
    1000.0
    
  4. 예제 4

    입력
    2 3 0 500
    0 0
    2 0
    3 1
    
    예상 출력
    353.5533905932738
    
  5. 예제 5

    입력
    3 4 0 10
    0 0
    10 0
    5 10
    5 5
    
    예상 출력
    50.0