-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path424B.txt
More file actions
49 lines (49 loc) · 709 Bytes
/
424B.txt
File metadata and controls
49 lines (49 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
struct locate
{
double x;
double y;
double value;
double dis;
};
bool comp(locate a,locate b)
{
return a.dis<b.dis;
}
int main()
{
locate s[1500];
for(int a,b;cin>>a>>b;)
{
for(int i=0;i<a;i++)
{
cin>>s[i].x>>s[i].y>>s[i].value;
s[i].dis=sqrt(s[i].x*s[i].x+s[i].y*s[i].y);
}
sort(s,s+a,comp);
double sum=b;
int index=0;
for(int j=0;j<a;j++)
{
if(sum<1000000)
{
sum+=s[j].value;
index=j;
}
else
break;
}
if(sum<1000000)
cout<<"-1"<<endl;
else
{
cout<<setiosflags(ios::fixed)<<setprecision(7)
<<s[index].dis<<endl;
}
}
return 0;
}