Language:default cows
Time Limit: 2000MS |
|
Memory Limit: 65536K |
Total Submissions: 7633 |
|
Accepted: 3467 |
Description Your friend to the south was interested in building fences and turning plowshares into swords. In order to help with his overseas adventure, they is forced to the save money on buying fence posts by using trees as fence Posts wherever possible. Given the locations of some trees, you be to help farmers a try to create the largest pasture this is possible. Not all the trees would need to be used. However, because you'll oversee the construction of the pasture yourself, all the farmers want to know are how many cows They can put in the pasture. It is the well known, a cow needs at least 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 Avai Lable Land. The next n lines contain the integer coordinates of each tree given as double integers x and yseparated by one space (where- 1000≤x, y≤1000). The integer coordinates correlate exactly to distance in metres (e.g., the distance between coordinate (ten;) and (11; 1 1) is one metre). Output You is to output a single integer value and the number of cows that can survive in the largest field you can construct using The available trees. Sample Input 4
0 0
0 101
0 75
101 Sample Output 151 |
Test instructions: Give some points to circle out a maximum area per 50 sq. A cow asks how many cows to raise.
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std
; struct point{int x, y;}
A[10010],RESULT[10010]; int Dist (point A,point B) {return (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y),} 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);
} BOOL CMP (point A,point b) {int ans=cp (A[0],A,B);
if (ans==0) return dist (a[0],a)-dist (a[0],b) <=0;
else return ans>0;
} int main () {int n,i,j;
while (scanf ("%d", &n)!=eof) {int pos=0;
for (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 (I=2;i<n;++i) {while (CP (RESULT[TOP-1],RESULT[TOP],A[I)) <0) top--;
Result[++top]=a[i]; } DOuble s=0; for (i=0;i<=top;++i) {double area= (result[(i+1)% (top+1)].x*result[i].y-result[(i+1)% (top+1)].y*result[i].x)/
2.0;
S+=area;
} printf ("%d\n", (int) (s/50.0));
} return 0; }