第一行输入两个整数
——点的数量与要求的权值下限。
接下来
行,第
行输入三个整数
,描述第
个点的坐标与权值。
若存在可行半径,在一行输出该最小半径
;否则输出
。
设你的输出为
,答案为
。当且仅当
时,你的答案将被判定为正确。
5 10 0 1 2 -1 1 3 3 3 4 -4 3 1 5 -3 1
5
当半径为时,
、
、
、
四个点被覆盖,权值和为
,达到要求。
5 10 0 1 2 -1 1 3 3 3 2 -4 3 1 5 -3 1
-1
权值和无法达到10
#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main()
{
int n,s;
std::cin>>n>>s;
long long x,y,v;
long long total=0;
std::map<long long,int> mymap;
for(int i=0;i<n;++i)
{
std::cin>>x>>y>>v;
total+=v;
mymap[x*x+y*y]+=v;
}
double ans = 0;
if(total<s)
ans = -1;
else
{
total=0;
for(auto& data : mymap)
{
total += data.second;
if(total>=s)
{
ans=std::sqrt(data.first);
break;
}
}
}
std::cout<<ans<<"\n";
}