#include <bits/stdc++.h>
using namespace std;
struct Item {
  double x, y;
  int p;
};
const int MAXN = 10000;
const long long INF = (long long)(1e18);
int n, s;
Item a[MAXN];
bool check(double R) {
  int temp = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i].x * a[i].x + a[i].y * a[i].y <= R * R) temp += a[i].p;
  }
  if (temp >= s) return 1;
  return 0;
}
int main() {
  cin >> n >> s;
  s = 1000000 - s;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].x >> a[i].y >> a[i].p;
  }
  long long l = 0, r = (long long)(1e16);
  double ans = INF, R = 0;
  while (l <= r) {
    long long mid = (l + r) / 2;
    R = double(mid) / (100000000000.0);
    if (check(R)) {
      ans = min(ans, R);
      r = mid - 1;
    } else
      l = mid + 1;
  }
  if (ans == INF)
    cout << "-1";
  else
    printf("%.7f", ans);
  return 0;
}
