Problem:
Score : 800 points

Problem Statement

There are N lines in the xy-plane. The i-th line is represented by A_ix+B_iy=C_i.
Any two lines among the N+2 lines, the above N lines plus the x-axis and y-axis, cross each other at exactly one point.

For each pair 1 \leq i < j \leq N, there is a car at the cross point of the i-th and j-th lines.
Even where three or more lines intersect at a point, a car is individually placed for each pair of lines.
That is, there will be k(k-1)/2 cars placed at the intersection of k lines.

Those cars are already very old, and can only be moved parallel to the x-axis or y-axis.

Takahashi will hold an exhibition of antique cars at a place on the xy-plane.
In order to avoid damaging the half-broken cars too much, he will select the place of the exhibition so that the total distance covered will be minimized when all the cars are moved to the place.
If such a place is not uniquely determined, among the places that satisfy the condition above, the place with the minimum x-coordinate will be selected.
If the place is still not uniquely determined, among the places that satisfy the two conditions above, the place with the minimum y-coordinate will be selected.

Find the place of the exhibition that will be selected.

Constraints

2 \leq N \leq 4 × 10^4

1 \leq |A_i|,|B_i| \leq 10^4(1 \leq i \leq N)

0 \leq |C_i| \leq 10^4(1 \leq i \leq N)

No two given lines are parallel.

All input values are integers.

Inputs

Input is given from Standard Input in the following format:

N
A_1 B_1 C_1
:
A_N B_N C_N

Outputs

Print the x-coordinate and y-coordinate of the place of the exhibition that will be selected, in this order, with a space in between. The output will be judged as correct when the absolute or relative error is at most 10^{-9}.

Sample Input 1

3
1 1 1
2 -1 2
-1 2 2

Sample Output 1

1.000000000000000 1.000000000000000

There is a car at each place shown by a blue circle in the figure. The place to be selected is shown by a purple circle.

Sample Input 2

4
1 1 2
1 -1 0
3 -1 -2
1 -3 4

Sample Output 2

-1.000000000000000 -1.000000000000000

Sample Input 3

7
1 7 8
-2 4 9
3 -8 -5
9 2 -14
6 7 5
-8 -9 3
3 8 10

Sample Output 3

-1.722222222222222 1.325000000000000

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.*;
import java.util.*;

class BinaryIndexedTree {
  private final int n;
  private final int[] values;
  
  BinaryIndexedTree(int n) {
    this.n = n;
    this.values = new int[n + 1];
  }
  
  public int sum(int index) {
    int value = 0;
    while (index > 0) {
      value += values[index];
      index -= index & -index;
    }
    return value;
  }
  
  public void add(int index, int value) {
    while (index <= n) {
      values[index] += value;
      index += index & -index;
    }
  }
}

class DI implements Comparable<DI> {
  final double d;
  final int i;
  
  DI(double d, int i) {
    this.d = d;
    this.i = i;
  }
  
  public int compareTo(DI di) {
    return Double.compare(this.d, di.d);
  }
}

class SubSolver {
  final int n;
  final double[] as, bs, cs;
  int[] tangentRanks;
  
  
  SubSolver(int n, double[] as, double[] bs, double[] cs) {
    this.n = n;
    this.as = as;
    this.bs = bs;
    this.cs = cs;
  }
  
  // ax + by = c
  // y = -(a/b) x + c/b
  private void setUpTangentRanks() {
    DI[] dis = new DI[n];
    for (int i = 0; i < n; i++) {
      dis[i] = new DI(-1.0 * as[i] / bs[i], i);
//      System.err.printf("%d: %f\n", i, -1.0 * as[i] / bs[i]);
    }
    Arrays.sort(dis);
    
    tangentRanks = new int[n];
    for (int i = 0; i < n; i++) {
      tangentRanks[dis[i].i] = i + 1;
    }
    
    /*
    for (int i = 0; i < n; i++) {
      System.err.printf("%d: %d\n", i, tangentRanks[i]);
    }
    */
  }
  
  private long count(double x) {
//    System.err.printf("Count: %f\n", x);
    DI[] dis = new DI[n];
    for (int i = 0; i < n; i++) {
      dis[i] = new DI((cs[i] - as[i] * x) / bs[i], i);
//      System.err.printf("%d: %f\n", i, dis[i].d);
    }
    Arrays.sort(dis);
    
    int[] xTangentRanks = new int[n];
    for (int i = 0; i < n; i++) {
      xTangentRanks[i] = tangentRanks[dis[i].i];
//      System.err.printf("%d, ", xTangentRanks[i]);
    }
//    System.err.println();
    
    BinaryIndexedTree binaryIndexedTree = new BinaryIndexedTree(n);
    long answer = 0;
    for (int i = 0; i < n; i++) {
      int v = xTangentRanks[i];
      binaryIndexedTree.add(v, 1);
      answer += i + 1 - binaryIndexedTree.sum(v);
    }
    
    return answer;
  }
  
  public double solve() {
    setUpTangentRanks();
    
    long longN = n;
    long targetCount = (longN * (longN - 1) / 2 + 2) / 2;
//    System.err.printf("Target count: %d\n", targetCount);
    double minX = -1e12;
    double maxX = 1e12;
    for (int i = 0; i < 64; i++) {
      double midX = (minX + maxX) / 2;
      long c = count(midX);
//      System.err.printf("%f %f %f %d\n", minX, maxX, midX, c);
      if (c < targetCount) {
        maxX = midX;
      } else {
        minX = midX;
      }
    }
    
    return maxX;
  }
}

class Solver {
  final int n;
  final double[] as, bs, cs;
  
  Solver(int n, double[] as, double[] bs, double[] cs) {
    this.n = n;
    this.as = as;
    this.bs = bs;
    this.cs = cs;
  }
  
  public String solve() {
    double x = new SubSolver(n, as, bs, cs).solve();
    double y = new SubSolver(n, bs, as, cs).solve();
    return String.format("%.20f %.20f", x, y);
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    double[] as = new double[n];
    double[] bs = new double[n];
    double[] cs = new double[n];
    for (int i = 0; i < n; i++) {
      as[i] = reader.nextInt();
      bs[i] = reader.nextInt();
      cs[i] = reader.nextInt();
    }
    out.println(new Solver(n, as, bs, cs).solve());
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}