思路:简单树状数组

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pb push_back
#define mp make_pair
#define Maxn 120
#define Maxm 80002
#define LL __int64
#define Abs(x) ((x)>0?(x):(-x))
#define lson(x) (x<<1)
#define rson(x) (x<<1|1)
#define inf 0x7fffffff
#define lowbit(x) (x&(-x))
#define Mod 1000000007
using namespace std;
int c[Maxn][Maxn],w,h,n;
void update(int x,int y)
{
    int yy=y;
    while(x<=w){
        y=yy;
        while(y<=h){
            c[x][y]++;
            y+=lowbit(y);
        }
        x+=lowbit(x);
    }
}
int sum(int x,int y)
{
    int sum=0,yy=y;
    while(x){
        y=yy;
        while(y){
            sum+=c[x][y];
            y-=lowbit(y);
        }
        x-=lowbit(x);
    }
    return sum;
}
int main()
{
    int n,i,j,x,y;
    while(scanf("%d",&n)!=EOF,n){
        memset(c,0,sizeof(c));
        scanf("%d%d",&w,&h);
        for(i=1;i<=n;i++){
            scanf("%d%d",&x,&y);
            update(x,y);
        }
        scanf("%d%d",&x,&y);
        int ans=0;
        for(i=x;i<=w;i++){
            for(j=y;j<=h;j++){
                ans=max(ans,sum(i,j)-sum(i-x,j)-sum(i,j-y)+sum(i-x,j-y));
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

 

相关文章:

  • 2022-03-02
  • 2021-09-06
  • 2022-12-23
  • 2022-03-04
  • 2021-08-20
  • 2021-11-25
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2021-06-07
  • 2022-12-23
  • 2021-07-05
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
相关资源
相似解决方案