Under construction

Still being built. Things may change

Largest Triangle

Time limit1sMemory limit2048 MB

Summary
Given an x-monotone terrain polyline from y=0 to y=0, find the largest-area triangle inside the terrain that has one vertex at one of the interior points p2 to p(n-1).
Level

Hard8 of 10

Topics
Geometry, Divide and conquer, Two pointers
Solved
No attempts yet

Problem

A terrain is an xx-monotone polygon defined by the points p1,…,pnp_1, \dots, p_n, where each point pip_i has coordinates (xi,yi)(x_i, y_i), and the following three conditions hold:

  • y1=yn=0y_1 = y_n = 0
  • yi>0y_i > 0 for 1<i<n1 < i < n
  • xi<xi+1x_i < x_{i+1} for 1≤i<n1 \le i < n

Given a terrain defined by the points p1,…,pnp_1, \dots, p_n, find the largest triangle that lies entirely within the terrain and has one of its three vertices at one of the terrain points p2p_2 through pn−1p_{n-1}.

Input

The first line contains an integer nn, the number of points in the terrain (3≤n≤1053 \le n \le 10^5). Each of the next nn lines contains two space-separated integers xix_i and yiy_i, the coordinates of point pip_i (0≤xi,yi≤1090 \le x_i, y_i \le 10^9).

Output

Print the area of the largest triangle that lies entirely within the terrain. A answer is accepted if its absolute or relative error is at most 10−610^{-6}.

Examples1

  1. Example 1

    Input
    11
    0 0
    2 10
    4 5
    6 7
    8 8
    10 4
    12 6
    14 4
    15 4
    16 7
    17 0
    
    Expected output
    53.666667