fork(1) download
  1. #pragma GCC optimized("-O3")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define ll long long
  5. #define ld long double
  6. #define lf __float128
  7. #define pb push_back
  8. #define x first
  9. #define y second
  10. int n;
  11. const int N=2e5+5;
  12. ld x[N],y[N];
  13. ld efs=1e-15;
  14. bool f(lf r){
  15. ld minx,maxx;
  16. minx=-1e12,maxx=1e12;
  17. int i;
  18. for(i=1;i<=n;i++){
  19. lf val;
  20. val=fabs((ld)r-y[i]);
  21. if(y[i]>r+r)
  22. return 0;
  23. ld temp;
  24. temp=((r*r)-(val*val));
  25. temp=sqrt(temp);
  26. minx=max(minx,x[i]-temp);
  27. maxx=min(maxx,x[i]+temp);
  28. }
  29. return minx<=(maxx+efs);
  30. }
  31. int main(){
  32. ios::sync_with_stdio(false);
  33. cin.tie(0);
  34. cout.tie(0);
  35. int i;
  36. //assert(freopen("input.txt","r",stdin));
  37. //assert(freopen("output.txt","w",stdout));
  38. cin>>n;
  39. int f1=0,f2=0;
  40. for(i=1;i<=n;i++){
  41. cin>>x[i]>>y[i];
  42. if(y[i]<0)
  43. f2++;
  44. if(y[i]>0)
  45. f1++;
  46. y[i]=fabs(y[i]);
  47. }
  48. //cout<<f1<<" "<<f2;
  49. if(f1*f2){
  50. cout<<-1;
  51. return 0;
  52. }
  53. ld l=0,r=1e18;
  54. //cout<<f(0);
  55. for(i=(n>100?55:200);i;i--){
  56. lf mid;
  57. mid=(l+r)/2;
  58. if(f(mid))
  59. r=mid;
  60. else
  61. l=mid;
  62. }
  63. cout<<fixed<<setprecision(20);
  64. cout<<(l+r)/2;
  65. return 0;
  66. }
Success #stdin #stdout 0s 21488KB
stdin
20

7571542 9868879

3634934 5986987

2297651 5538795

9701582 8250721

-2913168 4968483

8838674 5771883

-3348778 8326335

-577797 750161

-7223138 9113512

-1808146 6044926

-756446 417388

4700417 1550148

-5568937 20029

-9170707 6103893

7445655 7161843

8820510 4145867

-4466974 9280518

5842792 1905697

-8784063 3253524

-796596 1060279
stdout
28974952.66802237000229069963