public void solve() throws IOException {
    while (true) {
      int n = nextInt();
      if (n == 0)
        break;
      ArrayList<Trapezoid> available = new ArrayList<Trapezoid>();
      for (int x = 0; x < n; x++)
        available.add(new Trapezoid(nextInt(), nextInt(), nextInt()));

      double cost = minCost(nextInt(), nextInt(), available);
      int dollars = (int) (2 * cost / 100);
      int cents = (int) (2 * cost) % 100;
      String str = String.valueOf(cents);
      if (cents < 10)
        str = "0" + str;
      System.out.println(dollars + "." + str);
    }
  }