#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct node {
  int pos, v, op;
} p[N];
int n, s;
bool judge(double t) {
  bool l = false, r = false;
  long long lf_l = (long long)1e6, lf_r = 0, rt_l = (long long)1e6, rt_r = 0;
  for (int i = 0; i < n; i++) {
    if (p[i].op == 1) {
      double pos = (double)p[i].pos - (p[i].v + s) * t;
      if (pos > 0.0) continue;
      l = true;
      pos = (double)p[i].pos - p[i].v * t;
      if (pos <= 0.0) {
        lf_l = 0;
        lf_r = (long long)1e6;
        continue;
      }
      double mn_t = (double)(p[i].pos - t * p[i].v) / s;
      long long x2 = p[i].pos + floor((t - mn_t) * (s - p[i].v));
      lf_l = min(lf_l, (long long)p[i].pos);
      lf_r = max(lf_r, x2);
    } else {
      double pos = (double)p[i].pos + (p[i].v + s) * t;
      if (pos < 1e6) continue;
      r = true;
      pos = (double)p[i].pos + p[i].v * t;
      if (pos >= 1e6) {
        rt_l = 0;
        rt_r = 1e6;
        continue;
      }
      double mn_t = (double)(1e6 - p[i].pos - p[i].v * t) / s;
      long long x2 = p[i].pos - floor((t - mn_t) * (s - p[i].v));
      rt_l = min(rt_l, x2);
      rt_r = max(rt_r, (long long)p[i].pos);
    }
  }
  if (!l || !r) return false;
  if ((lf_l > lf_r) || (rt_l > rt_r)) return false;
  if (lf_l > rt_r || rt_l > lf_r)
    return false;
  else
    return true;
}
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) scanf("%d%d%d", &p[i].pos, &p[i].v, &p[i].op);
  double l = 0.0, r = 1e6, ans = 1e6;
  for (int i = 1; i <= 55; i++) {
    double mid = (l + r) / 2;
    if (judge(mid)) {
      r = mid;
      ans = min(ans, mid);
    } else
      l = mid;
  }
  printf("%.8f\n", ans);
  return 0;
}
