You are given a strictly convex polygon. Find the minimal possible area of non-degenerate triangle whose vertices are the vertices of the polygon.
Input
The first line contains a single integer n (3 ≤ n ≤ 200000) — the number of polygon vertices.
Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of polygon vertices.
The polygon is guaranteed to be strictly convex. Vertices are given in the counterclockwise order.
Output
It is known that the area of triangle whose vertices are the integer points on the grid is either integer or half-integer.
Output a single integer — the required area, multiplied by 2.
Examples
Input
4
0 1
3 0
3 3
-1 3
Output
5
Input
3
0 0
1 0
0 1
Output
1
Input
4
-999999991 999999992
-999999993 -999999994
999999995 -999999996
999999997 999999998
Output
3999999948000000156
Note
It is recommended to make all calculations using integer numbers, because floating point precision most likely would not be enough.
题意:
按逆时针的顺序给出一个凸多边形的n个顶点,求一个顶点都在凸多边形上,面积最小的三角形,输出三角形面积的二倍
二阶矩阵的行列式(两向量叉积)是求其平行四边形面积,三阶矩阵的行列式即求其平行六面体的体积。另外如果a×b<0,那么a在b的逆时针方向(通俗的理解,假设朝上的话,那么a在b的左边),反之亦然。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn = 2e5+10;
ll a[maxn];
ll n,m;
ll x[maxn],y[maxn];
ll minn = 0x3f3f3f3f3f3f3f3f;
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n;
int i;
ll ans;
for(i=0; i<n; i++)
{
cin>>x[i]>>y[i];
}
for(i=0; i<n; i++)
{
ll x1 = x[i] - x[(i+1)%n];
ll y1 = y[i] - y[(i+1)%n];
ll x2 = x[i] - x[(i+2)%n];
ll y2 = y[i] - y[(i+2)%n];
ans = (ll)abs(x1*y2-y1*x2);
minn = min(ans,minn);
}
cout<<minn<<endl;
return 0;
}