;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (inline relative-error-p))
(defun relative-error<= (x y threshold)
  "Returns true if the relative error between X and Y is equal to or smaller
than THRESHOLD: i.e. the relative errors of any numbers in the interval [X,
Y] (or [Y, X]) are equal to or smaller than THRESHOLD when the true value is in
the same interval."
  (and (not (zerop x))
       (not (zerop y))
       (<= (abs (/ (- x y) y)) threshold)
       (<= (abs (/ (- x y) x)) threshold)))

;;;
;;; ARRAY-ELEMENT-TYPE is not constant-folded on SBCL version earlier than
;;; 1.5.0. See
;;; https://github.com/sbcl/sbcl/commit/9f0d12e7ab961828931d01c0b2a76a5885ad35d2
;;;

(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-c:deftransform array-element-type ((array))
    (let ((type (sb-c::lvar-type array)))
      (flet ((element-type (type)
               (and (sb-c::array-type-p type)
                    (sb-int:neq (sb-kernel::array-type-specialized-element-type type) sb-kernel:*wild-type*)
                    (sb-kernel:type-specifier (sb-kernel::array-type-specialized-element-type type)))))
        (cond ((let ((type (element-type type)))
                 (and type
                      `',type)))
              ((sb-kernel:union-type-p type)
               (let (result)
                 (loop for type in (sb-kernel:union-type-types type)
                       for et = (element-type type)
                       unless (and et
                                   (if result
                                       (equal result et)
                                       (setf result et)))
                       do (sb-c::give-up-ir1-transform))
                 `',result))
              ((sb-kernel:intersection-type-p type)
               (loop for type in (sb-kernel:intersection-type-types type)
                     for et = (element-type type)
                     when et
                     return `',et
                     finally (sb-c::give-up-ir1-transform)))
              (t
               (sb-c::give-up-ir1-transform)))))))

;;;
;;; Compute inversion number by merge sort
;;;

(declaim (inline %merge-count))
(defun %merge-count (l mid r source-vec dest-vec predicate)
  (declare ((integer 0 #.array-total-size-limit) l mid r)
           (function predicate))
  (loop with count of-type (integer 0 #.most-positive-fixnum) = 0
        with i = l
        with j = mid
        for idx from l
        when (= i mid)
        do (loop for j from j below r
                 for idx from idx
                 do (setf (aref dest-vec idx)
                          (aref source-vec j))
                 finally (return-from %merge-count count))
        when (= j r)
        do (loop for i from i below mid
                 for idx from idx
                 do (setf (aref dest-vec idx)
                          (aref source-vec i))
                 finally (return-from %merge-count count))
        do (if (funcall predicate
                        (aref source-vec j)
                        (aref source-vec i))
               (setf (aref dest-vec idx) (aref source-vec j)
                     j (1+ j)
                     count (+ count (- mid i)))
               (setf (aref dest-vec idx) (aref source-vec i)
                     i (1+ i)))))

(defmacro the-fixnum+ (form)
  (let ((fixnum+ '(integer 0 #.most-positive-fixnum)))
    `(the ,fixnum+
          ,(reduce (lambda (f1 f2)`(,(car form)
                                   (the ,fixnum+ ,f1)
                                   (the ,fixnum+ ,f2)))
	           (cdr form)))))

(declaim (inline %calc-by-insertion-sort!))
(defun %calc-by-insertion-sort! (vec predicate l r)
  (declare (function predicate)
           ((integer 0 #.array-total-size-limit) l r))
  (loop with inv-count of-type (integer 0 #.most-positive-fixnum) = 0
        for end from (+ l 1) below r
        do (loop for i from end above l
                 while (funcall predicate (aref vec i) (aref vec (- i 1)))
                 do (rotatef (aref vec (- i 1)) (aref vec i))
                    (incf inv-count))
        finally (return inv-count)))

;; NOTE: This function is slow on SBCL version earlier than 1.5.0 as
;; constant-folding of ARRAY-ELEMENT-TYPE doesn't work. Use
;; array-element-type.lisp if necessary.
(declaim (inline calc-inversion-number!))
(defun calc-inversion-number! (vector predicate &key (start 0) end buffer)
  "Calculates the inversion number of VECTOR w.r.t. the strict order
PREDICATE. This function sorts VECTOR as a side effect."
  (declare ((simple-array double-float (*)) vector buffer)
           (function predicate))
  (let ((end (or end (length vector))))
    (declare ((integer 0 #.array-total-size-limit) start end))
    (assert (<= start end))
    (labels
        ((recur (l r merge-to-vec1-p)
           (declare (optimize (safety 0))
                    ((integer 0 #.array-total-size-limit) l r))
           (cond ((and (<= (- r l) 24) merge-to-vec1-p)
                  (%calc-by-insertion-sort! vector predicate l r))
                 (t
                  (let ((mid (floor (+ l r) 2)))
                    (the-fixnum+
                     (+ (recur l mid (not merge-to-vec1-p))
                        (recur mid r (not merge-to-vec1-p))
                        (if merge-to-vec1-p
                            (%merge-count l mid r buffer vector predicate)
                            (%merge-count l mid r vector buffer predicate)))))))))
      (recur start end t))))

(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun solve (n as bs cs)
  (declare #.OPT
           ((simple-array double-float (*)) as bs cs)
           (uint16 n))
  (let ((lefts (make-array n :element-type 'double-float))
        (rights (make-array n :element-type 'double-float))
        (median (ceiling (floor (* n (- n 1)) 2) 2))
        (buffer (make-array n :element-type 'double-float)))
    (dotimes (i n)
      (let ((y (/ (+ (aref cs i) (* 1d9 (aref as i)))
                  (aref bs i))))
        (setf (aref lefts i) y)))
    (let ((ords (make-array n :element-type 'uint32)))
      (dotimes (i n) (setf (aref ords i) i))
      (setf ords (sort ords
                       (lambda (i j)
                         (< (aref lefts i) (aref lefts j)))))
      (sb-int:named-let bisect ((ng -2d8) (ok 2d8))
        (declare (double-float ng ok))
        (if (or (< (- ok ng) 1d-10)
                (relative-error<= ng ok 1d-10))
            ok
            (let ((mid (* 0.5d0 (+ ng ok))))
              (dotimes (i n)
                (let* ((ord (aref ords i))
                       (y (/ (- (aref cs ord) (* mid (aref as ord)))
                             (aref bs ord))))
                  (setf (aref rights i) y)))
              (let ((invs (calc-inversion-number! rights #'< :buffer buffer)))
                (if (>= invs median)
                    (bisect ng mid)
                    (bisect mid ok)))))))))

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (as (make-array n :element-type 'double-float))
         (bs (make-array n :element-type 'double-float))
         (cs (make-array n :element-type 'double-float)))
    (dotimes (i n)
      (setf (aref as i) (float (read-fixnum) 1d0)
            (aref bs i) (float (read-fixnum) 1d0)
            (aref cs i) (float (read-fixnum) 1d0)))
    (let ((x (solve n as bs cs))
          (y (solve n bs as cs)))
      (format t "~F ~F~%" x y))))

#-swank (main)


Measured memory_bytes: 45664