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

20738번 - Tram 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB46363278.049%

문제

It is 1815 and the politicians in Lund have just decided to build a tram line in Lund. Oh, sorry. That was wrong, let's start over. It is 2015 and the politicians in Lund have just decided to build a tram line in Lund.

The politicians have already decided that the tram line should run from south-east to north-west. In order not to cause too many complaints from the citizens, they want to make the line as useful as possible. Therefore they want to minimize the total unusefulness of the tram.

The unusefulness for citizen $i$ is equal to the square of the closest distance from the citizen's home to the tram line. The total unusefulness of the tram is the sum of all citizens' unusefulnesses.

Given the coordinates of each citizen's home, determine the value $a$ minimizing the total unusefulnes, where the equation of the tram line is given by $y=x+a$.

입력

The first line of input consists of an integer, 1ドル\leq N\leq 10^5,ドル the number of citizens in Lund. Then follow $N$ lines, with two space-separated integers $x_i,y_i$ ($|x_i|,|y_i|\leq 10^6$), the coordinates of citizen $i$'s home.

출력

The output consists of a single number, $a,ドル minimizing the total unusefulness. An answer will be accepted if it is within an absolute or relative error of 10ドル^{-3}$.

제한

예제 입력 1

3
1 1
2 2
3 3

예제 출력 1

0.000000

예제 입력 2

3
0 1
1 0
1 1

예제 출력 2

0.000000

예제 입력 3

3
0 2
1 1
1 0

예제 출력 3

0.333333

힌트

출처

Contest > Swedish Coding Cup > LTH Challenge 2020 D번

  • 문제를 만든 사람: Lars Åström
(追記) (追記ここまで)

출처

대학교 대회

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

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