Your friend to the south is interested in building fences and turning plowshares into swords. In order to help with his overseas adventure, they are forced to save money on buying fence posts by using trees as fence posts wherever possible. Given the locations of some trees, you are to help farmers try to create the largest pasture that is possible. Not all the trees will need to be used.
However, because you will oversee the construction of the pasture yourself, all the farmers want to know is how many cows they can put in the pasture. It is well known that a cow needs at least 50 square metres of pasture to survive.
Input
The first line of input contains a single integer, n (1 ≤ n ≤ 10000), containing the number of trees that grow on the available land. The next n lines contain the integer coordinates of each tree given as two integers x and y separated by one space (where -1000 ≤ x, y ≤ 1000). The integer coordinates correlate exactly to distance in metres (e.g., the distance between coordinate (10; 11) and (11; 11) is one metre).
Output
You are to output a single integer value, the number of cows that can survive on the largest field you can construct using the available trees.
Sample Input
4
0 0
0 101
75 0
75 101
Sample Output
151
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <stack>
#define INF 2100000000
#define ll long long
#define clr(x) memset(x, 0, sizeof x)
using namespace std;
struct point { int x,y; } A[10010], result[10010];
inline int dist(point a, point b) { return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); }
inline int cp(point p1,point p2,point p3) { return (p3.x-p1.x)*(p2.y-p1.y)-(p3.y-p1.y)*(p2.x-p1.x); }
inline bool cmp(point a, point b) {
int ans = cp(A[0], a, b);
if(!ans) return dist(A[0], a)-dist(A[0], b) <= 0;
else return ans > 0;
}
int main() {
int n;
while(scanf("%d",&n) != EOF) {
int pos = 0;
for(register int i = 0; i < n; i++) {
scanf("%d%d",&A[i].x,&A[i].y);
if(A[pos].y >= A[i].y) {
if(A[pos].y == A[i].y){
if(A[pos].x > A[i].x) pos = i;
}
else pos = i;
}
}
if(n < 3) { printf("0\n"); continue; }
point temp; int top = 1;
temp = A[0]; A[0] = A[pos]; A[pos] = temp;
sort(A+1, A+n, cmp);
result[0] = A[0]; result[1] = A[1];
for(register int i = 2; i < n; i++) {
while(cp(result[top-1], result[top], A[i]) < 0) top--;
result[++top] = A[i];
}
double s = 0;
for(register int i = 0; i <= top; i++)
s += (result[(i+1)%(top+1)].x*result[i].y-result[(i+1)%(top+1)].y*result[i].x)/2.0;
printf("%d\n",(int)(s/50.0));
}
return 0;
}