import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
static class Node {
double x, y, v;
Node(double x, double y, double v) {
this.x = x;
this.y = y;
this.v = v;
}
}
static void solve() {
int n = in.nextInt();
double m = in.nextDouble();
Node[] a = new Node[n + 1];
double s = 0;
for (int i = 1; i <= n; i++) {
double x = in.nextDouble();
double y = in.nextDouble();
double v = in.nextDouble();
a[i] = new Node(x, y, v);
s += v;
}
if (s < m) {
out.println(-1);
return;
}
double l = 0, r = 1e12;
while (Math.abs(r-l)>1e-6) {
double mid = (l + r) / 2.0;
long sum = 0;
for (int i = 1; i <= n; i++) {
double dis = a[i].x * a[i].x + a[i].y * a[i].y;
if (dis <= mid * mid) {
sum += a[i].v;
}
}
if (sum >= m) {
r = mid;
} else {
l = mid;
}
}
out.printf("%.10f\n", l);
}
public static void main(String[] args) {
solve();
out.flush();
}
static FastReader in = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
static class FastReader {
static BufferedReader br;
static StringTokenizer st;
FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
String str = "";
while (st == null || !st.hasMoreElements()) {
try {
str = br.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
st = new StringTokenizer(str);
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
}