2429: [HAOI2006] Clever Monkey

Source: Internet
Author: User

2429: [HAOI2006] Smart Monkey time limit:10 Sec Memory limit:128 MB
submit:448 solved:309
[Submit] [Status] [Discuss] Description A group of monkeys living in a tropical rainforest, living on the fruit of trees. Yesterday a heavy rain, and now the rain, but the entire rainforest surface is still flooded with water, some of the plant's canopy dew on the surface. Monkeys can not swim, but the ability to jump more than the strong, they are still exposed to the surface of the different canopy on the shuttle to find the fruit like to eat. Now, there are n trees out of the water in this area, assuming that each tree itself is small in diameter and negligible. When we establish a Cartesian coordinate system on this area, the position of each tree is represented by its corresponding coordinates (the coordinates of any two trees are different). The monkeys living in this area had m, and when it rained, they hid in the dense and tall canopy, not swept away by the flood. Because each monkey's age is different, the physique is different, they jump ability is different. Some monkeys jump far from the distance (of course, can also jump to a closer tree), and some monkeys jumping distance is relatively close. These monkeys are very clever, and they can accurately determine whether they will jump to the opposite tree by visual inspection. The "problem" is now known about the number of monkeys and the maximum jumping distance for each monkey, and knowing the coordinates of each tree revealing the surface of the water, your task is to count how many monkeys can feed on all the canopies that are exposed to the surface of the area. Input

The 1th act is an integer that represents the number of monkeys M (2<=m<=500);

The 2nd behavior is M integers, which in turn indicate the maximum jumping distance for monkeys (each integer value is between 1--1000);

The 3rd Act an integer represents the total tree number N (2<=n<=1000);

Line 4th to n+3 the coordinates of the n tree (the horizontal ordinate is an integer, the range is: -1000--1000).

(separated by a space between integers on the same line)

Output

Includes an integer that indicates the number of monkeys that can forage on all the canopy in the area

Sample Input 4
1 2 3 4
6
0 0
1 0
1 2
-1-1
-2 0
2 2
Sample Output3hint

For 40% data, 2<=n <=100,1<=m<=100 is guaranteed.


For all data, 2<=n <= is guaranteed 1000,1<=m=500



Source

Day2

Puzzle: A bare minimum spanning tree, directly after the judgment is a = =

1/**************************************************************2Problem:24293 User:hansbug4 language:pascal5 result:accepted6Time:396Ms7Memory:11976KB8****************************************************************/9  Ten var One I,j,k,l,m,n,mm:longint; AB:Array[0.. -,1..2] ofLongint; -A:Array[0..1000005,1..3] ofLongint; -C,d:Array[0.. -] ofLongint; the functionMax (x,y:longint): Longint;inline; -          begin -               ifX>y ThenMax:=xElsemax:=y; -          End; + procedureSwapvarx,y:longint); inline; -           varZ:longint; +           begin Az:=x;x:=y;y:=Z; at           End; - proceduresort (l,r:longint); inline; -           varI,j,x,y:longint; -           begin -i:=l;j:=r;x:=a[(L+r)Div 2,3]; -                Repeat in                       whileA[i,3]<x DoInc (i); -                       whileA[j,3]>x DoDec (j); to                      ifI<=j Then +                         begin -Swap (A[i,1],a[j,1]); theSwap (A[i,2],a[j,2]); *Swap (A[i,3],a[j,3]); $ Inc (I);d EC (j);Panax Notoginseng                         End; -                untilI>J; the                ifI<r Thensort (i,r); +                ifL<j Thensort (l,j); A           End; the functionGetfat (x:longint): Longint;inline; +          begin -               ifX&LT;&GT;C[X] Thenc[x]:=Getfat (c[x]); $ exit (C[x]); $          End; - begin - Readln (m); the       fori:=1  toM Doread (d[i]); -readln;l:=0; Readln (n);Wuyi       fori:=1  toN DoREADLN (B[i,1],b[i,2]); the       fori:=1  toN-1  Do -           forj:=i+1  toN Do Wu              begin -Inc (L); A[l,1]:=i;a[l,2]:=J; AboutA[l,3]:= (B[i,1]-b[j,1]) * (B[i,1]-b[j,1]) + (B[i,2]-b[j,2]) * (B[i,2]-b[j,2]); $              End; -Sort1, L); -       fori:=1  toN Doc[i]:=i; -j:=0; mm:=0; A       fori:=1  toN-1  Do +          begin the               Repeat - Inc (J); $K:=getfat (A[j,1]); theL:=getfat (A[j,2]); the               untilK<>l; theMm:=max (Mm,a[j,3]); thec[k]:=l; -          End; inl:=0; the       fori:=1  toM Do if(D[i]*d[i]) >=mm ThenInc (L); the Writeln (l); About Readln; the End.

2429: [HAOI2006] Clever Monkey

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.