传送门

There is a forest that we model as a plane and live nn rare animals. Animal number iihas its lair in the point (xi,yi)(xi,yi). In order to protect them, a decision to build a nature reserve has been made.

The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through the forest. All animals drink from this river, therefore it must have at least one common point with the reserve. On the other hand, ships constantly sail along the river, so the reserve must not have more than one common point with the river.

For convenience, scientists have made a transformation of coordinates so that the river is defined by y=0y=0. Check whether it is possible to build a reserve, and if possible, find the minimum possible radius of such a reserve.

Input

The first line contains one integer nn (1≤n≤1051≤n≤105) — the number of animals.

Each of the next nn lines contains two integers xixi, yiyi (−107≤xi,yi≤107−107≤xi,yi≤107) — the coordinates of the ii-th animal's lair. It is guaranteed that yi≠0yi≠0. No two lairs coincide.

Output

If the reserve cannot be built, print −1−1. Otherwise print the minimum radius. Your answer will be accepted if absolute or relative error does not exceed 10−610−6.

Formally, let your answer be aa, and the jury's answer be bb. Your answer is considered correct if |a−b|max(1,|b|)≤10−6|a−b|max(1,|b|)≤10−6.

Examples

Input
1
0 1
Output
0.5
Input
3
0 1
0 2
0 -3
Output
-1
Input
2
0 1
1 1
Output
0.625

Note

In the first sample it is optimal to build the reserve with the radius equal to 0.50.5 and the center in (0, 0.5)(0, 0.5).

In the second sample it is impossible to build a reserve.

In the third sample it is optimal to build the reserve with the radius equal to 5858 and the center in (12, 58)(12, 58).

题意:一个圆与X轴相切,问最小的半径,使得圆包含所有给定的点。

题解:显然,所有的点必须都要在y轴的同一边才可以,之后二分半径,求取每一个点在枚举半径的时候的圆心的区间值

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#include<stack>
#include<cstdlib>
#include <vector>
#include <set>
#include<queue>
#include<map>
using namespace std; #define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
const int maxn = 1e5+;
const ll mod = 1e9+;
const double eps = 1e-; double x[maxn],y[maxn];
long double maxx = 100000000000000000.0;
int n;
bool check(long double k)
{
long double l = -maxx,r = maxx;
long double t;
for(int i=;i<=n;i++)
{
if(y[i] > k*)
return false;
t = sqrt(y[i]*(*k-y[i]));
if(l < x[i]-t)
l = x[i]-t;
if(r > x[i]+t)
r =x[i]+t;
}
return l<r;
}
int main()
{
scanf("%d",&n);
for(int i = ;i <= n;i++)
scanf("%lf %lf",&x[i],&y[i]);
for(int i=;i<=n;i++)
{
if(y[i] * y[n] < )
{
puts("-1");
return ;
}
else
y[i] = max(y[i],-y[i]);
}
long double l = ,r = maxx,mid;
for(int i=;i<=;i++)
{
mid = (l+r)/2.0;
if(check(mid))
r = mid;
else
l = mid;
}
printf("%.8Lf\n",mid);
return ;
}

E - Nature Reserve CodeForces - 1059D的更多相关文章

  1. [CodeForces]1059D Nature Reserve

    大意:给你一个平面上N(N<=100000)个点,问相切于x轴的圆,将所有的点都覆盖的最小半径是多少. 计算几何???Div2的D题就考计算几何???某人昨天上课才和我们说这种计算几何题看见就溜 ...

  2. Codeforces Round #514 (Div. 2):D. Nature Reserve(二分+数学)

    D. Nature Reserve 题目链接:https://codeforces.com/contest/1059/problem/D 题意: 在二维坐标平面上给出n个数的点,现在要求一个圆,能够容 ...

  3. Nature Reserve

    Nature Reserve time limit per test:2 seconds memory limit per test:256 megabytes input:standard inpu ...

  4. CodeForces - 1059D(二分+误差)

    链接:CodeForces - 1059D 题意:给出笛卡尔坐标系上 n 个点,求与 x 轴相切且覆盖了所有给出点的圆的最小半径. 题解:二分半径即可.判断:假设当前二分到的半径是 R ,因为要和 x ...

  5. Codeforces Round #514 (Div. 2) D. Nature Reserve

    http://codeforces.com/contest/1059/problem/D 最大值: 最左下方和最右下方分别有一个点 r^2 - (r-1)^2 = (10^7)^2 maxr<0 ...

  6. [ CodeForces 1059 D ] Nature Reserve

    \(\\\) \(Description\) 你现在有\(N\)个分布在二维平面上的整点\((x_i,y_i)\),现在需要你找到一个圆,满足: 能够覆盖所有的给出点 与\(x\)轴相切 现在需要你确 ...

  7. CF1059D Nature Reserve

    原题链接 网络不好的可以到洛谷上去QwQ 题目大意 有N个点,求与y=0相切的,包含这N个点的最小圆的半径 输入输出样例 输入: 2 0 1 1 1 输出 0.625 感觉最多是蓝题难度? 首先无解的 ...

  8. D - Nature Reserve(cf514,div2)

    题意:给出n(n<=1e5)个点,求一个最小的圆,与x轴相切,并且包含这n个点 思路:我第一想到的是,这个圆一定会经过一个点,再根据与x轴相切,我们可以找到最小的圆,让它包含其余的点,但是如何判 ...

  9. cf1059D. Nature Reserve(三分)

    题意 题目链接 Sol 欲哭无泪啊qwq....昨晚一定是智息了qwq 说一个和标算不一样做法吧.. 显然\(x\)轴是可以三分的,半径是可以二分的. 恭喜你获得了一个TLE的做法.. 然后第二维的二 ...

随机推荐

  1. jquery常用属性与方法

    1..css( )给指定的样式设置样式值: 2..attr(attributeName,value) /.removeAttr(attributeName);给指定的属性设置值 / 清除所有匹配的元素 ...

  2. 转:ACCESS数据库转ORACLE数据库分享

    来源: 作者:zz 网上有很多文章介绍access转oracle数据库的方法,本人都尝试了,不是很成功,列举一下,后来人不必盲目试了,基本不成功: 1.Access-->excel-->P ...

  3. vos语音业务规范操作承诺函

    语音业务规范操作承诺函 *****网络科技有限公司: 我司开通固话2000线,话务价格为0.045元/分钟(仅拨打中国移动网内电话).为防止投诉.网外电话.欠费等语音话务风险,我司承诺如下:在业务上遵 ...

  4. 【BZOJ1067】[SCOI2007] 降雨量(RMQ+分类讨论)

    点此看题面 大致题意:请你判断"\(x\)年是自\(y\)年以来降雨量最多的"这句话的真假. 离散化/\(lower\_bound\) 首先,考虑到年份的范围非常大,便可以离散化. ...

  5. 使用 NetBackup 命令创建 Hyper-V 策略(命令创建其他策略也是如此)

    Veritas NetBackup™ for Hyper-V 管理指南 Product(s): NetBackup (8.1) 使用 NetBackup 命令创建 Hyper-V 策略 本主题介绍如何 ...

  6. centos6 yum 安装 install c++4.8 gcc4.8

    cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo yum --enablerep ...

  7. F​l​a​s​h​ ​M​e​d​i​a​ ​L​i​v​e​ ​E​n​c​o​d​e​r​参​数​表

    Flash Media Live Encoder命令行推流Flash Media Live Encoder NotesFlash Media Live Encoder 除了直接以 GUI 方式操作之外 ...

  8. Spring boot 异常处理配置

    1.    新建Maven项目 exception 2.   pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0&quo ...

  9. apache日志

    <VirtualHost *:80> ServerAdmin chinasir.xyz@gmail.com DocumentRoot /var/www/html/baidu ServerN ...

  10. 我是如何根据豆瓣api来理解Restful API设计的

    1.什么是REST REST全称是Representational State Transfer,表述状态转移的意思.它是在Roy Fielding博士论文首次提出.REST本身没有创造新的技术.组件 ...