尼玛,INF不能定义太大,找标程对拍了好久
1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 using namespace std; 9 #define MOD 1000000007 10 const int INF=2e9; 11 const double eps=1e-5; 12 typedef long long ll; 13 #define cl(a) memset(a,0,sizeof(a)) 14 #define ts printf("***** "); 15 const int MAXN=10000; 16 int n,m,tt; 17 struct Node 18 { 19 int x,y; 20 void in() 21 { 22 scanf("%d%d",&x,&y); 23 } 24 }node[MAXN]; 25 bool cmp(Node a,Node b) 26 { 27 return a.y<b.y; 28 } 29 int ans[MAXN],R,tot; 30 int main() 31 { 32 int i,j,k; 33 #ifndef ONLINE_JUDGE 34 freopen("1.in","r",stdin); 35 #endif 36 while(scanf("%d%d",&n,&R)!=EOF) 37 { 38 for(i=0;i<n;i++) 39 { 40 scanf("%d%d",&node[i].x,&node[i].y); 41 } 42 sort(node,node+n,cmp); 43 int MAX=0,e; 44 for(i=0;i<n;i++) 45 { 46 tot=0; 47 for(j=0;j<n;j++) 48 { 49 if(node[j].y>=node[i].y&&node[j].y<=node[i].y+R) 50 ans[tot++]=node[j].x; 51 } 52 sort(ans,ans+tot); 53 ans[tot++]=INF; 54 e=0; 55 for(j=0;j<tot-1;j++) 56 { 57 while(ans[e]<=ans[j]+R) e++; 58 MAX=max(MAX,(e-j)); 59 } 60 } 61 printf("%d ",MAX); 62 } 63 }