POJ 2029 Get Many Persimmon Trees
[cpp]
#include <stdio.h>
#include <cstring>
const int maxn=101;
int c[maxn][maxn];
inline int lowbit(int x)
{
return x&(-x);
}
void update(int x,int y)
{
for(int i=x; i<=maxn; i+=lowbit(i))
for(int j=y; j<=maxn; j+=lowbit(j))
c[i][j]+=1;
}
int sum(int x,int y)
{
int ans=0;
for(int i=x; i>0; i-=lowbit(i))
for(int j=y; j>0; j-=lowbit(j))
ans+=c[i][j];
return ans;
}
int main()
{
int n,w,h,x,y,s,t;
while(scanf("%d",&n)==1&&n)
{
memset(c,0,sizeof(c));
scanf("%d%d",&w,&h);
for(int i=1; i<=n; i++)
{
scanf("%d%d",&x,&y);
update(x,y);
}
scanf("%d%d",&s,&t);
int ans=-1;
for(int i=1; i<=w; i++)
for(int j=1; j<=h; j++)
{ www.zzzyk.com
if(i+s-1>w||j+t-1>h) continue;
int temp=sum(i+s-1,j+t-1)-sum(i-1,j+t-1)-sum(i+s-1,j-1)+sum(i-1,j-1);
if(temp>ans) ans=temp;
}
printf("%d\n",ans);
}
return 0;
}
补充:软件开发 , C++ ,